/**
  * @param ItemId[] $links
  *
  * @return SiteLinkLookup
  */
 private function getSiteLinkLookup(array $links)
 {
     $siteLinkLookup = new HashSiteLinkStore();
     foreach ($links as $pageId => $itemId) {
         $pageName = self::PAGE_NAME_PREFIX . $pageId;
         $item = new Item($itemId);
         $item->getSiteLinkList()->addNewSiteLink('testwiki', $pageName);
         $item->getSiteLinkList()->addNewSiteLink('badwiki', $pageName);
         $item->getSiteLinkList()->addNewSiteLink('sadwiki', 'Other stuff');
         $siteLinkLookup->saveLinksOfItem($item);
     }
     return $siteLinkLookup;
 }
 public function testDeleteLinksOfItem()
 {
     $itemId = new ItemId('Q111');
     $siteLink = new SiteLink('eswiki', 'Gato');
     $item = new Item($itemId);
     $item->getSiteLinkList()->addSiteLink($siteLink);
     $siteLinkStore = new HashSiteLinkStore();
     $siteLinkStore->saveLinksOfItem($item);
     $this->assertEquals($itemId, $siteLinkStore->getItemIdForSiteLink($siteLink));
     $siteLinkStore->deleteLinksOfItem($itemId);
     $this->assertEmpty($siteLinkStore->getSiteLinksForItem($itemId), 'get by item id');
     $this->assertNull($siteLinkStore->getItemIdForSiteLink($siteLink), 'get by site link');
 }
 public function testGetSiteLinkPageName_usage()
 {
     $item = $this->getItem();
     $entityLookup = new MockRepository();
     $entityLookup->putEntity($item);
     $siteLinkStore = new HashSiteLinkStore();
     $siteLinkStore->saveLinksOfItem($item);
     $usages = new HashUsageAccumulator();
     $wikibaseLuaBindings = $this->getWikibaseLuaBindings($entityLookup, $siteLinkStore, $usages);
     $itemId = $item->getId();
     $wikibaseLuaBindings->getSiteLinkPageName($itemId->getSerialization());
     $this->assertTrue($this->hasUsage($usages->getUsages(), $itemId, EntityUsage::TITLE_USAGE), 'title usage');
     $this->assertFalse($this->hasUsage($usages->getUsages(), $itemId, EntityUsage::LABEL_USAGE), 'label usage');
     $this->assertFalse($this->hasUsage($usages->getUsages(), $itemId, EntityUsage::ALL_USAGE), 'all usage');
 }