public function testCreateClassName() { $kit = new controller\Kit('path', ['namespacePrefix' => 'testPrefix']); $this->assertEquals('testPrefix\\path\\sub\\Controller', $kit->createClassName('/path/SUB', 'ControLLer')); $kit = new controller\Kit('path', ['namespacePrefix' => '']); $this->setExpectedException('UnexpectedValueException', 'Namespace prefix must be non empty by security reasons.'); $kit->createClassName('/path/SUB', 'ControLLer'); }
/** * Make controller instance. * * @param $controllerPath * @param $controller * @param $action * @throws \RuntimeException * @return array */ public function makeController($controllerPath, $controller, $action) { $controllerInstance = $this->controllerKit->makeController($controllerPath, $controller, $action); if (!$controllerInstance) { throw new \RuntimeException('Controller not found. Path:"' . $controllerPath . '", Controller:"' . $controller . '". Action:"' . $action . '".', 404); } return ['instance' => $controllerInstance, 'action' => $this->controllerKit->getActionMethod($action)]; }