5 * @covers SpecialMyLanguage
7 class SpecialMyLanguageTest
extends MediaWikiTestCase
{
8 public function addDBData() {
13 foreach ( $titles as $title ) {
14 $page = WikiPage
::factory( Title
::newFromText( $title ) );
15 if ( $page->getId() == 0 ) {
17 new WikitextContent( 'UTContent' ),
21 User
::newFromName( 'UTSysop' ) );
27 * @covers SpecialMyLanguage::findTitle
28 * @dataProvider provideFindTitle
29 * @param string $expected
30 * @param string $subpage
31 * @param string $langCode
32 * @param string $userLang
34 public function testFindTitle( $expected, $subpage, $langCode, $userLang ) {
35 $this->setMwGlobals( 'wgLanguageCode', $langCode );
36 $special = new SpecialMyLanguage();
37 $special->getContext()->setLanguage( $userLang );
38 // Test with subpages both enabled and disabled
39 $this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', array( NS_MAIN
=> true ) );
40 $this->assertTitle( $expected, $special->findTitle( $subpage ) );
41 $this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', array( NS_MAIN
=> false ) );
42 $this->assertTitle( $expected, $special->findTitle( $subpage ) );
46 * @param string $expected
47 * @param Title|null $title
49 private function assertTitle( $expected, $title ) {
51 $title = $title->getPrefixedText();
53 $this->assertEquals( $expected, $title );
56 public static function provideFindTitle() {
58 array( null, '::Fail', 'en', 'en' ),
59 array( 'Page/Another', 'Page/Another/en', 'en', 'en' ),
60 array( 'Page/Another', 'Page/Another', 'en', 'en' ),
61 array( 'Page/Another/ru', 'Page/Another', 'en', 'ru' ),
62 array( 'Page/Another', 'Page/Another', 'en', 'es' ),