protected function validate($scope = Validator::SCOPE_ALL, $options = null) { if (!$this->validationRun) { $form = $this->formHandler->getFormBlueprint(); if (method_exists($form, 'getValidationRules')) { $form->getValidationRules($this->validator); } $this->doFieldValidationRules($form->getAll()); $entities = $this->formHandler->saveToAndGetClonedEntities(); if (!empty($entities)) { foreach ($entities as $entity) { $this->validator->addSubValidation($entity['entity'], $entity['fields']); } } $this->validator->validate($this->formHandler->getData(), 'standard', $scope); $this->validationRun = true; } else { throw new \Exception("Can't validate twice, use existing validation result"); } }
public function testSaveToAndGetClonedEntities() { $entity = new StandardFormEntity(); $entity->setName('Name One'); $entity->setDescription('Description One'); $entity->setCategory('5'); $entity->setPassword('Secure One'); $this->standard_form_handler->bindEntity($entity); $_POST = $this->standard_form_request; $this->standard_form_handler->handleRequest(); $clones = $this->standard_form_handler->saveToAndGetClonedEntities(); $this->assertEquals('Name One', $entity->getName()); $this->assertEquals('Example Name', $clones[0]['entity']->getName()); }