mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-18 00:30:40 +00:00
Merge "LanguagesHelperTest: Use @dataProvider to configure test cases"
This commit is contained in:
commit
6954616670
|
@ -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() ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue