コード例 #1
0
 /**
  * @param array $diffOp
  *
  * @return DiffOp
  * @throws InvalidArgumentException
  */
 public function newFromArray(array $diffOp)
 {
     $this->assertHasKey('type', $diffOp);
     // see EntityDiff::getType() and ItemDiff::getType()
     if (preg_match('!^diff/(.*)$!', $diffOp['type'], $matches)) {
         $itemType = $matches[1];
         $this->assertHasKey('operations', $diffOp);
         $operations = $this->createOperations($diffOp['operations']);
         $diff = EntityDiff::newForType($itemType, $operations);
         return $diff;
     }
     return parent::newFromArray($diffOp);
 }
コード例 #2
0
 /**
  * @dataProvider invalidArrayFromArrayProvider
  *
  * @param array $array
  */
 public function testNewFromArrayInvalid(array $array)
 {
     $this->setExpectedException('InvalidArgumentException');
     $factory = new DiffOpFactory();
     $factory->newFromArray($array);
 }