public function testValidManagerWhenInvalidMethod() { $methods = $this->classManager->getMethods(); $methods->add(new MethodGetterManager($this->classManager)); // broken method $this->classManager->setMethods($methods); $errors = $this->getValidator()->validate($this->classManager); $this->assertEquals(1, $errors->count()); }
/** * 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; }