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); }
/** * Prepare correct ClassManager * * @param $newProperties ArrayCollection * @return ClassManager */ private function preapareClassManager() { $pureClassManager = Helper::prepareBasicClassManager("\\Tests\\HelloWordPl\\SimpleEntityGeneratorBundle\\Lib\\Dummies\\User"); $properties = $pureClassManager->getProperties(); $properties->add(Helper::prepareProperty('test_boolean', "boolean", "new boolean property", ["IsTrue()"])); $properties->add(Helper::prepareProperty('test_collection', "Doctrine\\Common\\Collections\\ArrayCollection", "new collection property", ["Valid()"])); $classManager = $this->container->get('seg.structure_generator')->preapareClassManager($pureClassManager); $errors = $this->container->get('validator')->validate($classManager); $this->assertFalse($errors->count() > 0); return $classManager; }