public function testValidManagerWhenEmptyProperty()
 {
     $this->initPropertyManager->setProperty(new PropertyManager());
     $errors = $this->getValidator()->validate($this->initPropertyManager);
     $this->assertEquals(4, $errors->count());
 }
 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);
 }
 /**
  * @param InitPropertyManager $initProperty
  * @return string
  * @throws RendererException
  */
 protected function renderInitProperty(InitPropertyManager $initProperty)
 {
     $template = $initProperty->getTemplate();
     $tags = $initProperty->getTemplateTags();
     $args[RenderableInterface::TAG_PROPERTY_NAME] = $initProperty->getProperty()->getPreparedName();
     $args[RenderableInterface::TAG_PROPERTY_TYPE] = sprintf('\\%s', $initProperty->getProperty()->getTypeName());
     return $this->addIndentation($this->replace($tags, $args, $template), self::INDENT_4_SPACES);
 }
 /**
  * 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;
 }