From: Kunal Mehta Date: Thu, 19 May 2016 22:09:19 +0000 (-0700) Subject: Add tests for Linker::getLinkColour() X-Git-Tag: 1.31.0-rc.0~6801 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=5f8a771f7e8bb03161bbc93b627a708fe55d42d8;p=lhc%2Fweb%2Fwiklou.git Add tests for Linker::getLinkColour() Change-Id: Ic1553e21def47f5c4923ba747146b36b0b3ffdfc --- diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 6215ba1a10..0dc12c7707 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -1,5 +1,7 @@ assertEquals( $expected, $out ); } + + /** + * @covers Linker::getLinkColour + */ + public function testGetLinkColour() { + $linkCache = MediaWikiServices::getInstance()->getLinkCache(); + $foobarTitle = Title::makeTitle( NS_MAIN, 'FooBar' ); + $redirectTitle = Title::makeTitle( NS_MAIN, 'Redirect' ); + $userTitle = Title::makeTitle( NS_USER, 'Someuser' ); + $linkCache->addGoodLinkObj( + 1, // id + $foobarTitle, + 10, // len + 0 // redir + ); + $linkCache->addGoodLinkObj( + 2, // id + $redirectTitle, + 10, // len + 1 // redir + ); + + $linkCache->addGoodLinkObj( + 3, // id + $userTitle, + 10, // len + 0 // redir + ); + + $this->assertEquals( + '', + Linker::getLinkColour( $foobarTitle, 0 ) + ); + + $this->assertEquals( + 'stub', + Linker::getLinkColour( $foobarTitle, 20 ) + ); + + $this->assertEquals( + 'mw-redirect', + Linker::getLinkColour( $redirectTitle, 0 ) + ); + + $this->assertEquals( + '', + Linker::getLinkColour( $userTitle, 20 ) + ); + } }