Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289782

Change subject: Add tests for Linker::getLinkColour()
......................................................................

Add tests for Linker::getLinkColour()

Change-Id: Ic1553e21def47f5c4923ba747146b36b0b3ffdfc
---
M tests/phpunit/includes/LinkerTest.php
1 file changed, 51 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/289782/1

diff --git a/tests/phpunit/includes/LinkerTest.php 
b/tests/phpunit/includes/LinkerTest.php
index 1bf8729..2005cce 100644
--- a/tests/phpunit/includes/LinkerTest.php
+++ b/tests/phpunit/includes/LinkerTest.php
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @group Database
  */
@@ -420,4 +422,53 @@
                $out = Linker::link( $title );
                $this->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 )
+               );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/289782
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1553e21def47f5c4923ba747146b36b0b3ffdfc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to