public function testErrorsIfAssertionIsValid() { $property = new entity\property\Property('car'); $property->addPropertyRule(new \dicom\workflow\rules\AlwaysTrueRule()); $executionResult = $property->executeRules('4 wheel', '4 wheel', $errors = []); static::assertTrue($executionResult->isSuccess()); }
protected function createTestGirl() { $boobsSize = new Property('boobsSize'); $greaterThenRule = new GreaterThan(); $greaterThenRule->setConfig(2); $boobsSize->addPropertyRule($greaterThenRule); $prettyFace = new Property('prettyFace'); $prettyFace->addPropertyRule(new AlwaysTrueRule()); $girl = new CompositeProperty('girl'); $girl->addProperty($boobsSize); $girl->addProperty($prettyFace); return $girl; }
/** * Сводить Rule валидатор в каждое правило * * @param Property $property * @return array */ protected function visitRuleValidatorToEachRule(Property $property) { $result = []; if ($property instanceof CompositeProperty) { foreach ($property->getProperties() as $subProperty) { $result[$subProperty->getName()] = $this->visit($subProperty); } } else { foreach ($property->getRules() as $rule) { $result[$rule->getName()] = $this->getRuleVisitor($rule)->visit($rule); } } return $result; }
/** * Создать Property содержащее правила * * @param $name * @param $rules * @return Property */ protected static function createLeafProperty($name, $rules) { $property = new Property($name); $property->setRules(RulesFactory::createBatchByShortNames($rules)); return $property; }
/** * app sub property * * @param Property $property */ public function addProperty(Property $property) { $this->properties[$property->getName()] = $property; }