public function testValidManagerWhenInvalidProperty()
 {
     $properties = $this->classManager->getProperties();
     $properties->add(new PropertyManager($this->classManager));
     // broken property
     $this->classManager->setProperties($properties);
     $errors = $this->getValidator()->validate($this->classManager);
     $this->assertEquals(4, $errors->count());
 }
 /**
  * @param string $namespace
  * @return ClassManager
  */
 public static function prepareBasicClassManager($namespace = "\\AppBundle\\Entity\\User")
 {
     $classManager = new ClassManager();
     $classManager->setNamespace($namespace);
     $classManager->setComment("User entity for tests");
     $propertiesCollection = new ArrayCollection();
     $propertiesCollection->add(self::prepareProperty("full_name", "string", "", ["NotBlank()"]));
     $propertiesCollection->add(self::prepareProperty("email", "string", "", ["Email(message = \"Invalid email!\")"]));
     $propertiesCollection->add(self::prepareProperty("active", "boolean", "Wether user active", ["Type(type='boolean')", "IsTrue()"]));
     $propertiesCollection->add(self::prepareProperty("new_posts", "Doctrine\\Common\\Collections\\ArrayCollection<AppBundle\\Entity\\Post>", "User new posts", ["NotNull()", "Valid()"]));
     $classManager->setProperties($propertiesCollection);
     return $classManager;
 }
 /**
  * Generate class components
  * - setters and getters for Class and Interface (optional)
  * - method with prefix is for boolean properties
  *
  * @param \HelloWordPl\SimpleEntityGeneratorBundle\Lib\ClassManager $classManager
  */
 protected function generateAndFillClassMethods(ClassManager $classManager)
 {
     $methodsForClass = new ArrayCollection();
     // fix - jms serializer does not call ClassManager constructor during deserialization
     if (false == $classManager->getProperties() instanceof ArrayCollection) {
         $classManager->setProperties(new ArrayCollection());
     }
     foreach ($classManager->getProperties() as $property) {
         if ($property->isTypeBoolean()) {
             $methodsForClass->add((new MethodGetterBooleanManager($classManager))->setProperty($property));
         }
         $methodSetterManager = new MethodSetterManager($classManager);
         $methodSetterManager->setProperty($property);
         $methodGetterManager = new MethodGetterManager($classManager);
         $methodGetterManager->setProperty($property);
         $methodsForClass->add($methodSetterManager);
         $methodsForClass->add($methodGetterManager);
     }
     $classManager->setMethods($methodsForClass);
     return $classManager;
 }