/** * @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); }
/** * @dataProvider invalidArrayFromArrayProvider * * @param array $array */ public function testNewFromArrayInvalid(array $array) { $this->setExpectedException('InvalidArgumentException'); $factory = new DiffOpFactory(); $factory->newFromArray($array); }