/** * @return bool */ protected function _validateData() { $sourceClassName = $this->_getSourceClassName(); $resultClassName = $this->_getResultClassName(); $resultFileName = $this->_ioObject->getResultFileName($resultClassName); // @todo the controller handling logic below must be removed when controllers become PSR-0 compliant $controllerSuffix = 'Controller'; $pathParts = explode('_', $sourceClassName); if (strrpos($sourceClassName, $controllerSuffix) === strlen($sourceClassName) - strlen($controllerSuffix) && isset($pathParts[2]) && !in_array($pathParts[2], array('Block', 'Helper', 'Model'))) { $controllerPath = preg_replace('/^([0-9A-Za-z]*)_([0-9A-Za-z]*)/', '\\1_\\2_controllers', $sourceClassName); $filePath = stream_resolve_include_path(str_replace('_', '/', $controllerPath) . '.php'); $isSourceClassValid = !empty($filePath); } else { $isSourceClassValid = $this->_autoloader->getFile($sourceClassName); } if (!$isSourceClassValid) { $this->_addError('Source class ' . $sourceClassName . ' doesn\'t exist.'); return false; } elseif ($this->_autoloader->getFile($resultClassName)) { $this->_addError('Result class ' . $resultClassName . ' already exists.'); return false; } elseif (!$this->_ioObject->makeGenerationDirectory()) { $this->_addError('Can\'t create directory ' . $this->_ioObject->getGenerationDirectory() . '.'); return false; } elseif (!$this->_ioObject->makeResultFileDirectory($resultClassName)) { $this->_addError('Can\'t create directory ' . $this->_ioObject->getResultFileDirectory($resultClassName) . '.'); return false; } elseif ($this->_ioObject->fileExists($resultFileName)) { $this->_addError('Result file ' . $resultFileName . ' already exists.'); return false; } return true; }
public function testGetResultFileDirectory() { $expectedDirectory = self::GENERATION_DIRECTORY . '/' . 'class/'; $this->assertEquals($expectedDirectory, $this->_object->getResultFileDirectory(self::CLASS_NAME)); }