X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FTitleTest.php;h=7850f2490cb86cd4b93aef61e7f01acc713b1e59;hb=b86ef89dd17f51841a220e8ef9b3b8b2402e2547;hp=496f18f796b84f61127f12df7330e7917c3dcf0d;hpb=bca436db920721302565801d47f370c17756de66;p=lhc%2Fweb%2Fwiklou.git 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() ); + } }