public function testConstructionDiffContainsAddOperations() { $item = new Item(); $item->getFingerprint()->setLabel('en', 'foo'); $item->getSiteLinkList()->addNewSiteLink('bar', 'baz'); $differ = new ItemDiffer(); $diff = $differ->getConstructionDiff($item); $this->assertEquals(new Diff(array('en' => new DiffOpAdd('foo'))), $diff->getLabelsDiff()); $this->assertEquals(new Diff(array('bar' => new Diff(array('name' => new DiffOpAdd('baz'))))), $diff->getSiteLinkDiff()); }
private function makeDiff($objectId, $revA, $revB) { $entityClasses = array(Item::ENTITY_TYPE => 'Wikibase\\DataModel\\Entity\\Item'); $lookup = $this->getEntityRevisionLookup(); $entityFactory = new EntityFactory($entityClasses); $itemId = new ItemId($objectId); if ($revA === 0) { $oldEntity = $entityFactory->newEmpty(Item::ENTITY_TYPE); } else { $oldEntity = $lookup->getEntityRevision($itemId, $revA)->getEntity(); } if ($revB === 0) { $newEntity = $entityFactory->newEmpty(Item::ENTITY_TYPE); } else { $newEntity = $lookup->getEntityRevision($itemId, $revB)->getEntity(); } $differ = new ItemDiffer(); return $differ->diffEntities($oldEntity, $newEntity); }