setMwGlobals( array( 'wgContLang' => Language::factory( 'en' ), ) ); } /** * Returns a mock GenderCache that will return "female" always. * * @return GenderCache */ private function getGenderCache() { $genderCache = $this->getMockBuilder( 'GenderCache' ) ->disableOriginalConstructor() ->getMock(); $genderCache->expects( $this->any() ) ->method( 'getGenderOf' ) ->will( $this->returnValue( 'female' ) ); return $genderCache; } public static function provideGetPageUrl() { return array( array( new TitleValue( NS_MAIN, 'Foo_Bar' ), array(), '/Foo_Bar' ), array( new TitleValue( NS_USER, 'Hansi_Maier', 'stuff' ), array( 'foo' => 'bar' ), '/User:Hansi_Maier?foo=bar#stuff' ), ); } /** * @dataProvider provideGetPageUrl */ public function testGetPageUrl( TitleValue $title, $params, $url ) { // NOTE: was of Feb 2014, MediaWikiPageLinkRenderer *ignores* the // WikitextTitleFormatter we pass here, and relies on the Linker // class for generating the link! This may break the test e.g. // of Linker uses a different language for the namespace names. $lang = Language::factory( 'en' ); $formatter = new MediaWikiTitleCodec( $lang, $this->getGenderCache() ); $renderer = new MediaWikiPageLinkRenderer( $formatter, '/' ); $actual = $renderer->getPageUrl( $title, $params ); $this->assertEquals( $url, $actual ); } public static function provideRenderHtmlLink() { return array( array( new TitleValue( NS_MAIN, 'Foo_Bar' ), 'Foo Bar', '!Foo Bar!' ), array( //NOTE: Linker doesn't include fragments in "broken" links //NOTE: once this no longer uses Linker, we will get "2" instead of "User" for the namespace. new TitleValue( NS_USER, 'Hansi_Maier', 'stuff' ), 'Hansi Maier\'s Stuff', '!renderWikitextLink( $title, $text ); $this->assertEquals( $expected, $actual ); } }