/** * Parses the request by checking if the requested Controller and Action exist, * as well as passing necessary arguments to the functions. * * @since 0.1.1 Refactored, create performAction() function * @since 0.0.9 */ private function parseRequest() { $controller_name = $this->request->getController(); $controller_file_path = __DIR__ . '/controllers/' . $controller_name . 'Controller.php'; if (file_exists($controller_file_path)) { $controller_namespace = 'Apollo\\Controllers\\' . $controller_name . 'Controller'; /** @var GenericController $controller */ $controller = new $controller_namespace(); $method = 'action' . $this->request->getAction(); if (!$this->request->hasAction()) { $controller->index(); } elseif (method_exists($controller, $method)) { $this->performAction($controller_namespace, $controller, $method); } else { $controller->notFound(); } } else { $this->request->error(404, 'Page not found! (Controller <b>' . $controller_name . '</b> not found)'); } }
/** * @dataProvider constructorProvider */ public function testController($url, $controller, $action, $parameters, $valid, $index, $query) { $request = new Request($url); $result = $request->getController() == $controller; $this->assertTrue($result); }