/**
  * @param TestClassManager $testClass
  * @return string
  * @throws RendererException
  */
 protected function renderTestClass(TestClassManager $testClass)
 {
     $template = $testClass->getTemplate();
     $tags = $testClass->getTemplateTags();
     $constructTestMethodBody = "";
     $methods = [];
     foreach ($testClass->getMethods() as $method) {
         $methods[] = $this->render($method);
     }
     $class = $testClass->getClassManager();
     $constructTestMethodBody .= $this->addNewLineAfter("\$this->assertNotNull(\$this->object);");
     if ($testClass->getClassManager()->hasInterface()) {
         $interfaceTestAssert = sprintf("\$this->assertInstanceof('%s', \$this->object);", $testClass->getClassManager()->getInterface()->getNamespace());
         $constructTestMethodBody .= $this->addNewLineAfter($this->addIndentation($interfaceTestAssert, self::INDENT_8_SPACES));
     }
     $classTestAssert = sprintf("\$this->assertInstanceof('%s', \$this->object);", $class->getNamespace());
     $constructTestMethodBody .= $this->addNewLineAfter($this->addIndentation($classTestAssert, self::INDENT_8_SPACES));
     if ($testClass->getClassManager()->hasExtends()) {
         $extendsTestAssert = sprintf("\$this->assertInstanceof('%s', \$this->object);", $testClass->getClassManager()->getExtends());
         $constructTestMethodBody .= $this->addNewLineAfter($this->addIndentation($extendsTestAssert, self::INDENT_8_SPACES));
     }
     $testObjectType = $class->getNamespace();
     if ($class->hasInterface()) {
         $testObjectType = $class->getInterface()->getNamespace();
     }
     $args[RenderableInterface::TAG_NAMESPACE] = $testClass->getNamespaceWithoutNameAndBackslashPrefix();
     $args[RenderableInterface::TAG_COMMENT] = $testClass->getComment();
     $args[RenderableInterface::TAG_NAME] = $testClass->getName();
     $args[RenderableInterface::TAG_CLASS] = $class->getNamespace();
     $args[RenderableInterface::TAG_METHODS] = Tools::implodeArrayToTemplate($methods);
     $args[RenderableInterface::TAG_TEST_OBJECT_TYPE] = $testObjectType;
     $args[RenderableInterface::TAG_METHOD_BODY] = $constructTestMethodBody;
     return $this->addNewLineAfter($this->replace($tags, $args, $template));
 }
 public function testValidManagerWhenInvalidClassManager()
 {
     $this->testClassManager->setClassManager(new ClassManager());
     $errors = $this->getValidator()->validate($this->testClassManager);
     $this->assertEquals(3, $errors->count());
 }
 /**
  * @param string $content
  * @param TestClassManager $item
  * @param ReflectionClass $reflectionClass
  * @return string
  */
 protected function getUpdatedTestClassContent($content, TestClassManager $item, ReflectionClass $reflectionClass)
 {
     $item->setMethods($this->resolveMethodsToRender($item, $reflectionClass));
     return $this->getRenderer()->renderAndPutItemsToContent($content, $item->getMethods(), $this->getNewMethodPostion($reflectionClass));
 }
 /**
  * init test class for entity
  *
  * @param TestClassManager $testClassManager
  * @return TestClassManager
  */
 protected function generateAndFillTestClassMethods(TestClassManager $testClassManager)
 {
     $testMethods = new ArrayCollection();
     foreach ($testClassManager->getClassManager()->getMethods() as $method) {
         $testMethod = new TestMethodManager();
         $testMethod->setMethod($method);
         $testMethods->add($testMethod);
     }
     $testClassManager->setMethods($testMethods);
     return $testClassManager;
 }