public function test_processDocBlock() { /** === Test Data === */ $TYPE = 'type name'; $CONTENTS = "line1\nline2"; $PROP_TYPE = 'property type'; $PROP_DATA = new \Praxigento\Core\Reflection\Data\Property(); $PROP_DATA->setName('name'); $PROP_DATA->setIsRequired(true); $PROP_DATA->setType($PROP_TYPE); /** === Mock object itself === */ $this->obj = \Mockery::mock(TypePropertiesRegistry::class . '[_processDocLine, register]', $this->objArgs); /** === Setup Mocks === */ $mBlock = $this->_mock(\Zend\Code\Reflection\DocBlockReflection::class); // $docBlockLines = $block->getContents(); $mBlock->shouldReceive('getContents')->once()->andReturn($CONTENTS); // $propData = $this->_processDocLine($line); $this->obj->shouldReceive('_processDocLine')->twice()->andReturn($PROP_DATA); // $this->register($propType); $this->obj->shouldReceive('register')->twice()->with($PROP_TYPE); /** === Call and asserts === */ $this->obj->_processDocBlock($TYPE, $mBlock); }
/** * Process generally coded methods ("public function getProp()"). * * @param string $type Normalized type name. * @param \Zend\Code\Reflection\MethodReflection[] $methods Reflection of the type's methods. */ public function _processMethods($type, $methods) { foreach ($methods as $method) { $methodName = $method->getName(); $isGetter = strpos($methodName, 'get') === 0; $hasParams = $method->getNumberOfParameters() > 0; $isIterator = $methodName == 'getIterator'; /* only getters w/o parameters will be proceeded */ if ($isGetter && !$hasParams && !$isIterator) { $propName = lcfirst(substr($methodName, 3)); $typeData = $this->_typeProcessor->getGetterReturnType($method); $propType = $typeData['type']; $propIsRequired = $typeData['isRequired']; $propIsArray = $this->_toolsType->isArray($propType); $propType = $this->_toolsType->normalizeType($propType); $propData = new \Praxigento\Core\Reflection\Data\Property(); $propData->setName($propName); $propData->setIsRequired($propIsRequired); $propData->setIsArray($propIsArray); $propData->setType($propType); $this->_registry[$type][$propName] = $propData; $this->register($propType); } } }