rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / specials / SpecialMyLanguageTest.php
blob89fd1b06963a383138815e4c2392ced41c3d7737
1 <?php
3 /**
4 * @group Database
5 * @covers SpecialMyLanguage
6 */
7 class SpecialMyLanguageTest extends MediaWikiTestCase {
8 public function addDBDataOnce() {
9 $titles = [
10 'Page/Another',
11 'Page/Another/ru',
13 foreach ( $titles as $title ) {
14 $page = WikiPage::factory( Title::newFromText( $title ) );
15 if ( $page->getId() == 0 ) {
16 $page->doEditContent(
17 new WikitextContent( 'UTContent' ),
18 'UTPageSummary',
19 EDIT_NEW,
20 false,
21 User::newFromName( 'UTSysop' ) );
26 /**
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', [ NS_MAIN => true ] );
40 $this->assertTitle( $expected, $special->findTitle( $subpage ) );
41 $this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', [ NS_MAIN => false ] );
42 $this->assertTitle( $expected, $special->findTitle( $subpage ) );
45 /**
46 * @param string $expected
47 * @param Title|null $title
49 private function assertTitle( $expected, $title ) {
50 if ( $title ) {
51 $title = $title->getPrefixedText();
53 $this->assertEquals( $expected, $title );
56 public static function provideFindTitle() {
57 return [
58 [ null, '::Fail', 'en', 'en' ],
59 [ 'Page/Another', 'Page/Another/en', 'en', 'en' ],
60 [ 'Page/Another', 'Page/Another', 'en', 'en' ],
61 [ 'Page/Another/ru', 'Page/Another', 'en', 'ru' ],
62 [ 'Page/Another', 'Page/Another', 'en', 'es' ],