public function testGetItemIdForLink() { $item = new Item(); $item->getSiteLinkList()->addNewSiteLink('enwiki', 'Foo'); // test item lookup $this->repo->putEntity($item); $itemId = $item->getId(); $this->assertEquals($itemId, $this->repo->getItemIdForLink('enwiki', 'Foo')); $this->assertNull($this->repo->getItemIdForLink('xywiki', 'Foo')); // test lookup after item modification $item->getSiteLinkList()->setNewSiteLink('enwiki', 'Bar'); $this->repo->putEntity($item); $this->assertNull($this->repo->getItemIdForLink('enwiki', 'Foo')); $this->assertEquals($itemId, $this->repo->getItemIdForLink('enwiki', 'Bar')); // test lookup after item deletion $this->repo->removeEntity($itemId); $this->assertNull($this->repo->getItemIdForLink('enwiki', 'Foo')); $this->assertNull($this->repo->getItemIdForLink('enwiki', 'Bar')); }
public function testEntityDeleted() { $mock = new MockRepository(); $id = new ItemId('Q123'); $item = new Item($id); $mock->putEntity($item, 11); $lookup = new CachingEntityRevisionLookup($mock, new HashBagOStuff()); $lookup->setVerifyRevision(false); // fetch first revision, so it gets cached $lookup->getEntityRevision($id); // remove entity $mock->removeEntity($id); // now, notify the cache $lookup->entityDeleted($id); // make sure we get the new revision now $revId = $lookup->getLatestRevisionId($id); $this->assertFalse($revId, 'deletion should be detected after notification'); $rev = $lookup->getEntityRevision($id); $this->assertNull($rev, 'deletion should be detected after notification'); }