diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /tests/phpunit/includes/TitleMethodsTest.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'tests/phpunit/includes/TitleMethodsTest.php')
-rw-r--r-- | tests/phpunit/includes/TitleMethodsTest.php | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/phpunit/includes/TitleMethodsTest.php b/tests/phpunit/includes/TitleMethodsTest.php index 5904facd..e186438b 100644 --- a/tests/phpunit/includes/TitleMethodsTest.php +++ b/tests/phpunit/includes/TitleMethodsTest.php @@ -7,7 +7,7 @@ * @note We don't make assumptions about the main namespace. * But we do expect the Help namespace to contain Wikitext. */ -class TitleMethodsTest extends MediaWikiTestCase { +class TitleMethodsTest extends MediaWikiLangTestCase { protected function setUp() { global $wgContLang; @@ -297,4 +297,43 @@ class TitleMethodsTest extends MediaWikiTestCase { $title = Title::newFromText( $title ); $this->assertEquals( $expectedBool, $title->isWikitextPage() ); } + + public static function provideGetOtherPage() { + return array( + array( 'Main Page', 'Talk:Main Page' ), + array( 'Talk:Main Page', 'Main Page' ), + array( 'Help:Main Page', 'Help talk:Main Page' ), + array( 'Help talk:Main Page', 'Help:Main Page' ), + array( 'Special:FooBar', null ), + ); + } + + /** + * @dataProvider provideGetOtherpage + * @covers Title::getOtherPage + * + * @param string $text + * @param string|null $expected + */ + public function testGetOtherPage( $text, $expected ) { + if ( $expected === null ) { + $this->setExpectedException( 'MWException' ); + } + + $title = Title::newFromText( $text ); + $this->assertEquals( $expected, $title->getOtherPage()->getPrefixedText() ); + } + + public function testClearCaches() { + $linkCache = LinkCache::singleton(); + + $title1 = Title::newFromText( 'Foo' ); + $linkCache->addGoodLinkObj( 23, $title1 ); + + Title::clearCaches(); + + $title2 = Title::newFromText( 'Foo' ); + $this->assertNotSame( $title1, $title2, 'title cache should be empty' ); + $this->assertEquals( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' ); + } } |