public function testRenderAndPutConstructorBodyToContent() { $constructorManager = new ClassConstructorManager(new ClassManager()); $initProperties = new ArrayCollection(); $initProperty = new InitPropertyManager(); $initProperty->setProperty(Helper::prepareProperty("collection", "Doctrine\\Common\\Collections\\ArrayCollection", "items collection", ["Valid(message = \"Collection has to be valid!\")"])); $initProperty2 = new InitPropertyManager(); $initProperty2->setProperty(Helper::prepareProperty("collection2", "Doctrine\\Common\\Collections\\ArrayCollection", "items collection 2", ["Valid(message = \"Collection has to be valid!\")"])); $initProperties->add($initProperty2); $initProperties->add($initProperty); $constructorManager->setInitProperties($initProperties); $result = $this->renderer->renderAndPutConstructorBodyToContent($this->postClassExpected, $constructorManager, 43); $this->assertEquals($this->postClassWithUpdatedConstructor, $result); }
public function testValidManagerWhenEmptyProperty() { $this->initPropertyManager->setProperty(new PropertyManager()); $errors = $this->getValidator()->validate($this->initPropertyManager); $this->assertEquals(4, $errors->count()); }
/** * Prepare list of init properties for constructor * * @param ClassConstructorManager $classConstructor * @return ClassConstructorManager */ protected function prepareAndFillInitProperties(ClassConstructorManager $classConstructor) { $initProperties = new ArrayCollection(); foreach ($classConstructor->getClassManager()->getProperties() as $property) { if (false == $property->isTypeArrayCollection()) { continue; } $initProperty = new InitPropertyManager(); $initProperty->setProperty($property); $initProperties->add($initProperty); } $classConstructor->setInitProperties($initProperties); return $classConstructor; }