/** * Creates the view context */ public function __construct() { $path = array_reverse(explode('\\', get_class($this))); $moduleName = ''; $controllerName = 'index'; switch (count($path)) { case 3: $moduleName = Filter::camelCaseToDash($path[2]); case 2: $controllerName = Filter::camelCaseToDash($path[1]); case 1: $viewName = Filter::camelCaseToDash(substr($path[0], 8)); } $basePath = APPLICATION_PATH; if ($moduleName) { $basePath .= '/modules/' . $moduleName; } $this->_controllerName = $controllerName; $basePath .= '/views/'; if (!file_exists($basePath) || !is_dir($basePath)) { require_once 'Zend/Controller/Exception.php'; throw new \Zend_Controller_Exception('Missing base view directory ("' . $basePath . '")'); } require_once 'Zend/View.php'; $this->_view = new \Zend_View(array('basePath' => $basePath)); $this->_viewScript = $this->_controllerName . "/{$viewName}.phtml"; }
/** * @param string $exampleGroupName * @param string $specificationText * @return string * @throws \UnexpectedValueException */ public function getExampleMethod($exampleGroupName, $specificationText) { foreach ($this->examplesByGroup[$this->getExampleGroupClass($exampleGroupName)] as $exampleMethod) { /* @var $exampleMethod \ReflectionMethod */ if ($specificationText == Filter::camelCaseToSpace(substr($exampleMethod->getName(), 2))) { return $exampleMethod->getName(); } } throw new \UnexpectedValueException(sprintf('The example corresponding to [ %s ] and [ %s ] is not found in the test suite.', $specificationText, $exampleGroupName)); }
protected function getTestMethodName($testMethodName) { return Filter::camelCaseToSpace(substr($testMethodName, 2)); }
/** * Return the specification text taken from method name * * itReturnZeroWithNoArguments * becomes * returns zero with no argument * * @param string $methodName * @return string */ public function getSpecificationText() { $methodName = substr($this->_methodName, 2); return Filter::camelCaseToSpace($methodName); }