Fix config overrides in SkinVectorTest.

Use overrideConfigValues instead of installMockMwServices and setMwGlobals.
This ensures that configuration overrides are handled consistently.

This also fixes a data provider that relied on a service, which causes
the test to fail when not run via the pgpunit wrapper.

Depends-On: I898927717ce961d98617a7fcd9c7fa8e19bec412
Change-Id: I6354fa39e1e9adf4be6eb6b26db82b8f106c593e
This commit is contained in:
daniel 2022-07-16 11:48:56 +02:00 committed by Daniel Kinzler
parent 235c0872a6
commit bf67540431

View file

@ -2,7 +2,6 @@
namespace MediaWiki\Skins\Vector\Tests\Integration; namespace MediaWiki\Skins\Vector\Tests\Integration;
use Exception; use Exception;
use HashConfig;
use MediaWiki\MediaWikiServices; use MediaWiki\MediaWikiServices;
use MediaWikiIntegrationTestCase; use MediaWikiIntegrationTestCase;
use ReflectionMethod; use ReflectionMethod;
@ -121,10 +120,9 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
$tocData[ 'number-section-count' ] >= $config[ 'VectorTableOfContentsCollapseAtCount' ] $tocData[ 'number-section-count' ] >= $config[ 'VectorTableOfContentsCollapseAtCount' ]
]; ];
$expectedNestedTocData = array_merge( $nestedTocData, $expectedConfigData ); $expectedNestedTocData = array_merge( $nestedTocData, $expectedConfigData );
$context = RequestContext::getMain();
$buttonLabel = $context->msg( 'vector-toc-toggle-button-label', // qqx output
$expectedNestedTocData[ 'array-sections' ][ 0 ][ 'line' ] $buttonLabel = '(vector-toc-toggle-button-label: A)';
)->text();
$expectedNestedTocData[ 'array-sections' ][ 0 ][ 'vector-button-label' ] = $buttonLabel; $expectedNestedTocData[ 'array-sections' ][ 0 ][ 'vector-button-label' ] = $buttonLabel;
return [ return [
@ -186,10 +184,8 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
array $config, array $config,
array $expected array $expected
) { ) {
$this->setMwGlobals( [ $this->overrideConfigValues( $config );
'wgVectorTableOfContentsCollapseAtCount' => $config['VectorTableOfContentsCollapseAtCount'], $this->setUserLang( 'qqx' );
'wgVectorTableOfContentsBeginning' => $config['VectorTableOfContentsBeginning'],
] );
$skinVector = new SkinVector22( [ 'name' => 'vector-2022' ] ); $skinVector = new SkinVector22( [ 'name' => 'vector-2022' ] );
$openSkinVector = TestingAccessWrapper::newFromObject( $skinVector ); $openSkinVector = TestingAccessWrapper::newFromObject( $skinVector );
@ -439,12 +435,11 @@ class SkinVectorTest extends MediaWikiIntegrationTestCase {
bool $shouldHideLanguages, bool $shouldHideLanguages,
bool $expected bool $expected
) { ) {
$config = new HashConfig( array_merge( $requirements, [ $this->overrideConfigValues( array_merge( $requirements, [
'DefaultSkin' => 'vector-2022', 'DefaultSkin' => 'vector-2022',
'VectorDefaultSkinVersion' => '2', 'VectorDefaultSkinVersion' => '2',
'VectorSkinMigrationMode' => true, 'VectorSkinMigrationMode' => true,
] ) ); ] ) );
$this->installMockMwServices( $config );
$mockSkinVector = $this->getMockBuilder( SkinVector22::class ) $mockSkinVector = $this->getMockBuilder( SkinVector22::class )
->disableOriginalConstructor() ->disableOriginalConstructor()