WMDE-leszek has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/357572 )
Change subject: [DNM] Assert badge data is added in OtherProjectsSidebarGeneratorTest ...................................................................... [DNM] Assert badge data is added in OtherProjectsSidebarGeneratorTest With change Id2c94167b6ce29c8104818a12bc5dfa1e3435ef4 OtherProjectsSidebarGeneratorTest should verify that badge data is added to the sidebar link(s). This changes the test slightly compared to its form in PS6 of Id2c94167b6ce29c8104818a12bc5dfa1e3435ef4. This is not meant as the actual separate patch, rather only a demonstration of possible changes to Id2c94167b6ce29c8104818a12bc5dfa1e3435ef4. Change-Id: I4cf39921eb73bda5c54a253b22998ae79ff6554b --- M client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php 1 file changed, 26 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/72/357572/1 diff --git a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php index 0e1fe02..3ea2a85 100644 --- a/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php +++ b/client/tests/phpunit/includes/Hooks/OtherProjectsSidebarGeneratorTest.php @@ -4,15 +4,17 @@ use Closure; use HashSiteStore; +use Language; use MediaWikiSite; -use Prophecy\Argument; use SiteLookup; use Title; use TestSites; use Wikibase\Client\Hooks\OtherProjectsSidebarGenerator; use Wikibase\Client\Hooks\SidebarLinkBadgeDisplay; use Wikibase\DataModel\Entity\ItemId; +use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup; use Wikibase\DataModel\SiteLink; +use Wikibase\DataModel\Term\Term; use Wikibase\Lib\Store\SiteLinkLookup; /** @@ -65,9 +67,10 @@ ]; $wikipediaLink = [ 'msg' => 'wikibase-otherprojects-wikipedia', - 'class' => 'wb-otherproject-link wb-otherproject-wikipedia', + 'class' => 'wb-otherproject-link wb-otherproject-wikipedia badge-Q4242 badge-class', 'href' => 'https://en.wikipedia.org/wiki/Nyan_Cat', - 'hreflang' => 'en' + 'hreflang' => 'en', + 'itemtitle' => 'Badge Label', ]; return [ @@ -87,16 +90,16 @@ $this->getSidebarLinkBadgeDisplay() ], [ + [ 'enwiki' ], + [ $wikipediaLink ], + $this->getSidebarLinkBadgeDisplay() + ], + [ // Make sure results are sorted alphabetically by their group names [ 'enwiktionary', 'enwiki', 'enwikiquote' ], [ $wikipediaLink, $wikiquoteLink, $wiktionaryLink ], $this->getSidebarLinkBadgeDisplay() ], - [ - [ 'enwiki' ], - [ $wikipediaLink ], - $this->getSidebarLinkBadgeDisplay() - ] ]; } @@ -167,15 +170,17 @@ ); $wikipediaLink = array( 'msg' => 'wikibase-otherprojects-wikipedia', - 'class' => 'wb-otherproject-link wb-otherproject-wikipedia', + 'class' => 'wb-otherproject-link wb-otherproject-wikipedia badge-Q4242 badge-class', 'href' => 'https://en.wikipedia.org/wiki/Nyan_Cat', - 'hreflang' => 'en' + 'hreflang' => 'en', + 'itemtitle' => 'Badge Label', ); $changedWikipedaLink = array( 'msg' => 'wikibase-otherprojects-wikipedia', - 'class' => 'wb-otherproject-link wb-otherproject-wikipedia', + 'class' => 'wb-otherproject-link wb-otherproject-wikipedia badge-Q4242 badge-class', 'href' => 'https://en.wikipedia.org/wiki/Cat', - 'hreflang' => 'en' + 'hreflang' => 'en', + 'itemtitle' => 'Badge Label', ); return array( @@ -347,27 +352,16 @@ * @return SidebarLinkBadgeDisplay */ private function getSidebarLinkBadgeDisplay() { - $sidebarLinkBadgeDisplay = $this->prophesize( SidebarLinkBadgeDisplay::class ); + $labelDescriptionLookup = $this->getMock( LabelDescriptionLookup::class ); + $labelDescriptionLookup->method( 'getLabel' ) + ->with( new ItemId( 'Q4242' ) ) + ->will( $this->returnValue( new Term( 'en', 'Badge Label' ) ) ); - $sidebarLinkBadgeDisplay->getBadgeInfo( [ new ItemId( 'Q4242' ) ] ) - ->willReturn( [ 'data' ] ); - - $sidebarLinkBadgeDisplay->applyBadgeToLink( - [ - 'msg' => 'wikibase-otherprojects-wikipedia', - 'class' => 'wb-otherproject-link wb-otherproject-wikipedia', - 'href' => 'https://en.wikipedia.org/wiki/Nyan_Cat', - 'hreflang' => 'en' - ], - [ 'data' ] - )->willReturn( [ 'data' ] ); - - $sidebarLinkBadgeDisplay->getBadgeInfo( [] )->willReturn( [] ); - - $sidebarLinkBadgeDisplay->applyBadgeToLink( Argument::type( 'array' ), [] ) - ->willReturn( [] ); - - return $sidebarLinkBadgeDisplay->reveal(); + return new SidebarLinkBadgeDisplay( + $labelDescriptionLookup, + [ 'Q4242' => 'badge-class' ], + new Language( 'en' ) + ); } } -- To view, visit https://gerrit.wikimedia.org/r/357572 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4cf39921eb73bda5c54a253b22998ae79ff6554b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: WMDE-leszek <leszek.mani...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits