From: Kunal Mehta Date: Thu, 12 May 2016 18:14:47 +0000 (-0700) Subject: Add tests for Title::getPrefixedText() X-Git-Tag: 1.31.0-rc.0~6998^2~1 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=f3d0fa6b79d82a3d0e05c784273a5200244684db;p=lhc%2Fweb%2Fwiklou.git Add tests for Title::getPrefixedText() Change-Id: I2afd7ef8b6fd733dd2928a82e89b158fc6fab56d --- diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 496f18f796..7850f2490c 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -709,4 +709,42 @@ class TitleTest extends MediaWikiTestCase { $this->assertEquals( $title->getInterwiki(), $fragmentTitle->getInterwiki() ); $this->assertEquals( $fragment, $fragmentTitle->getFragment() ); } + + public function provideGetPrefixedText() { + return [ + // ns = 0 + [ + Title::makeTitle( NS_MAIN, 'Foobar' ), + 'Foobar' + ], + // ns = 2 + [ + Title::makeTitle( NS_USER, 'Foobar' ), + 'User:Foobar' + ], + // fragment not included + [ + Title::makeTitle( NS_MAIN, 'Foobar', 'fragment' ), + 'Foobar' + ], + // ns = -2 + [ + Title::makeTitle( NS_MEDIA, 'Foobar' ), + 'Media:Foobar' + ], + // non-existent namespace + [ + Title::makeTitle( 100000, 'Foobar' ), + ':Foobar' + ], + ]; + } + + /** + * @covers Title::getPrefixedText + * @dataProvider provideGetPrefixedText + */ + public function testGetPrefixedText( Title $title, $expected ) { + $this->assertEquals( $expected, $title->getPrefixedText() ); + } }