예제 #1
0
 public function testArrayDiff()
 {
     $old = array("0" => "hello", "1" => "testing", "2" => "diffarray");
     $new = array("0" => "hello", "1" => "TESTing", "2" => "diff_array");
     $output = array("0" => array("old" => "", "new" => "", "same" => "hello"), "1" => array("old" => "testing", "new" => "TESTing", "same" => ""), "2" => array("old" => "diffarray", "new" => "diff_array", "same" => ""));
     $diff = new ArrayDiff();
     $d = $diff->diff($old, $new);
     $this->assertEquals($output, $d);
 }
예제 #2
0
 /**
  * Get an array with the differences of between two specific revisions of
  * an object with a given id.
  *
  * @param  string $className
  * @param  int    $id
  * @param  int    $oldRevision
  * @param  int    $newRevision
  * @return array
  */
 public function diff($className, $id, $oldRevision, $newRevision)
 {
     $oldObject = $this->find($className, $id, $oldRevision);
     $newObject = $this->find($className, $id, $newRevision);
     $oldValues = $this->getEntityValues($className, $oldObject);
     $newValues = $this->getEntityValues($className, $newObject);
     $differ = new ArrayDiff();
     return $differ->diff($oldValues, $newValues);
 }