Ejemplo n.º 1
0
 /**
  * @param EntityDocument $entity
  *
  * @return EntityDiff
  * @throws InvalidArgumentException
  */
 public function getDestructionDiff(EntityDocument $entity)
 {
     $this->assertIsProperty($entity);
     /** @var Property $entity */
     $diffOps = $this->diffPropertyArrays($this->toDiffArray($entity), array());
     $diffOps['claim'] = $this->statementListDiffer->getDiff($entity->getStatements(), new StatementList());
     return new EntityDiff($diffOps);
 }
Ejemplo n.º 2
0
 public function diffProvider()
 {
     $diffs = array();
     $diffOps = array('label' => new Diff(array('en' => new DiffOpAdd('foobar'), 'de' => new DiffOpRemove('onoez'), 'nl' => new DiffOpChange('foo', 'bar')), true));
     $diffs[] = new EntityDiff($diffOps);
     $diffOps['description'] = new Diff(array('en' => new DiffOpAdd('foobar'), 'de' => new DiffOpRemove('onoez'), 'nl' => new DiffOpChange('foo', 'bar')), true);
     $diffs[] = new EntityDiff($diffOps);
     $diffOps['aliases'] = new Diff(array('en' => new Diff(array(new DiffOpAdd('foobar'), new DiffOpRemove('onoez')), false), 'de' => new Diff(array(new DiffOpRemove('foo')), false)), true);
     $diffs[] = new EntityDiff($diffOps);
     $statement = new Statement(new PropertyNoValueSnak(42));
     $statement->setGuid('EntityDiffTest$foo');
     $statementListDiffer = new StatementListDiffer();
     $diffOps['claim'] = $statementListDiffer->getDiff(new StatementList($statement), new StatementList());
     $diffs[] = new EntityDiff($diffOps);
     $argLists = array();
     foreach ($diffs as $diff) {
         $argLists[] = array($diff);
     }
     return $argLists;
 }
Ejemplo n.º 3
0
 public function diffItems(Item $from, Item $to)
 {
     $diffOps = $this->recursiveMapDiffer->doDiff($this->toDiffArray($from), $this->toDiffArray($to));
     $diffOps['claim'] = $this->statementListDiffer->getDiff($from->getStatements(), $to->getStatements());
     return new ItemDiff($diffOps);
 }
 private function assertResultsInDiff(StatementList $fromStatements, StatementList $toStatements, Diff $diff)
 {
     $differ = new StatementListDiffer();
     $actual = $differ->getDiff($fromStatements, $toStatements);
     $this->assertEquals($diff, $actual);
 }