public function handleTestableMethod(\PhpUnitTestGenerator\Generator\TestMethod $method) { if ($this->isGetterMethod($method)) { $dummyValueType = "string"; foreach ($method->getOriginalMethod()->getDocBlocks()->getTags() as $tag) { /* @var $tag \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag */ if ($tag->getName() == "return") { $dummyValueType = $tag->getType(); break; } } $dummyValue = Generator::getInstance()->getValueByType($dummyValueType); $excepted = Generator::getInstance()->getExceptedValueByType($dummyValueType); $assertion = Generator::getInstance()->getAssertionByType($dummyValueType); $method->setStatus(\PhpUnitTestGenerator\Generator\TestMethod::STATUS_FINAL); $method->setContent(\PhpUnitTestGenerator\Resource\Helper::getParsedTemplateByNameAndHash('TestMethodGetter.tpl.dist', array('methodName' => ucfirst($method->getName()), 'origMethodName' => $method->getOriginalMethod()->getName(), 'className' => $method->getOriginalMethod()->getDeclaringClass()->getName(), 'methodShort' => str_replace('get', '', $method->getOriginalMethod()->getName()), 'dummyValue' => $dummyValue, 'excepted' => $excepted, 'assertion' => $assertion))); } elseif ($this->isSetterMethod($method)) { $dummyValueType = "string"; foreach ($method->getOriginalMethod()->getDocBlocks()->getTags() as $tag) { /* @var $tag \phpDocumentor\Reflection\DocBlock\Tag\ParamTag */ if ($tag->getName() == "param") { $dummyValueType = $tag->getType(); break; } } $dummyValue = Generator::getInstance()->getValueByType($dummyValueType); $excepted = Generator::getInstance()->getExceptedValueByType($dummyValueType); $assertion = Generator::getInstance()->getAssertionByType($dummyValueType); $method->setStatus(\PhpUnitTestGenerator\Generator\TestMethod::STATUS_ADDITIONAL); $method->setContent(\PhpUnitTestGenerator\Resource\Helper::getParsedTemplateByNameAndHash('TestMethodSetter.tpl.dist', array('methodName' => ucfirst($method->getName()), 'origMethodName' => $method->getOriginalMethod()->getName(), 'className' => $method->getOriginalMethod()->getDeclaringClass()->getName(), 'methodShort' => str_replace('set', '', $method->getOriginalMethod()->getName()), 'dummyValue' => $dummyValue, 'excepted' => $excepted, 'assertion' => $assertion))); } }