Merge "LanguagesHelperTest: Use @dataProvider to configure test cases"

This commit is contained in:
jenkins-bot 2024-03-11 07:18:51 +00:00 committed by Gerrit Code Review
commit 6954616670

View file

@ -58,44 +58,28 @@ class LanguagesHelperTest extends MediaWikiIntegrationTestCase {
} }
/** /**
* @dataProvider provideDoesTitleHasLanguagesOrVariants
* @param bool $hasVariants
* @param array $langLinks
* @param bool $expected
* @covers ::__construct * @covers ::__construct
* @covers ::doesTitleHasLanguagesOrVariants * @covers ::doesTitleHasLanguagesOrVariants
*/ */
public function testReturnsWhenOutputPageHasLangLinks() { public function testDoesTitleHasLanguagesOrVariants( bool $hasVariants, array $langLinks, bool $expected ) {
$helper = new LanguagesHelper( $helper = new LanguagesHelper(
$this->getLanguageConverterFactory( false ), $this->getLanguageConverterFactory( $hasVariants ),
$this->getOutput( [ 'pl:StronaTestowa', 'en:TestPage' ] ) $this->getOutput( $langLinks )
); );
$this->assertTrue( $helper->doesTitleHasLanguagesOrVariants( $this->getTitle() ) ); $this->assertSame( $expected, $helper->doesTitleHasLanguagesOrVariants( $this->getTitle() ) );
$helper = new LanguagesHelper(
$this->getLanguageConverterFactory( true ),
$this->getOutput( [ 'pl:StronaTestowa', 'en:TestPage' ] )
);
$this->assertTrue( $helper->doesTitleHasLanguagesOrVariants( $this->getTitle() ) );
} }
/** public static function provideDoesTitleHasLanguagesOrVariants() {
* @covers ::__construct return [
* @covers ::doesTitleHasLanguagesOrVariants [ false, [ 'pl:StronaTestowa', 'en:TestPage' ], true ],
*/ [ true, [ 'pl:StronaTestowa', 'en:TestPage' ], true ],
public function testReturnsWhenOutputDoesNotHaveLangLinks() { [ false, [], false ],
$helper = new LanguagesHelper( [ true, [], true ],
$this->getLanguageConverterFactory( false ), ];
$this->getOutput( [] )
);
$this->assertFalse( $helper->doesTitleHasLanguagesOrVariants(
$this->getTitle() ) );
$helper = new LanguagesHelper(
$this->getLanguageConverterFactory( true ),
$this->getOutput( [] )
);
$this->assertTrue( $helper->doesTitleHasLanguagesOrVariants(
$this->getTitle() ) );
} }
} }