/** * {@inheritDoc} */ public function validate($model) { if (!$this->supports($model)) { return new ViolationCollection(); } $violationCollection = $this->constraintValidator->validate($model); $structure = $model->getStructure(); if ($structure instanceof Contract) { $violationCollection->merge($this->contractValidator->validate($structure)); } if ($structure instanceof Object) { $violationCollection->merge($this->objectValidator->validate($structure)); } return $violationCollection; }
function it_also_validates_contract(Contract $contract, ContractValidator $contractValidator, File $model) { $violationCollection = new ViolationCollection(); $model->getStructure()->willReturn($contract); $contractValidator->validate($contract)->willReturn($violationCollection); $this->validate($model); }