public function testGetMissingConstructor() { $message = "test"; $exception = RouteException::getMissingConstructor($message); $this->assertEquals($exception->getMessage(), $message); $this->assertEquals($exception->getCode(), RouteException::MISSING_CONSTRUCTOR); }
protected function getController($destination) { $controllerStr = substr($destination, 0, strpos($destination, '@')); if (empty($controllerStr)) { throw RouteException::getInvalidController("Invalid controller destination given, must be in format " . "'Countroller@method'."); } $controller = null; if (!array_key_exists($controllerStr, $this->controllers)) { // We've not instantiated this controller yet. Do that. $className = 'App\\Controller\\' . $controllerStr; if (!class_exists($className)) { throw RouteException::getMissingConstructor("The given controller, {$className}, doesn't exist. " . "It either needs to be created in src\\Controller\\ or the spelling is incorrect."); } $this->controllers[$controllerStr] = new $className(); } return $this->controllers[$controllerStr]; }