/** * Tests that a CLI route with no appropriate handlers throws an * exception. */ public function testCliRouteWithNoHandler() { $config = $this->getStandardConfig(); $router = new SnappyRouter(new Config($config)); $_SERVER['argv'] = array('dummyScript.php', '--task', 'NotDefinedTask', '--action', 'anyAction'); $_SERVER['argc'] = count($_SERVER['argv']); $response = $router->handleRoute(); $expected = 'No CLI handler registered.' . PHP_EOL; $this->assertEquals($expected, $response); }
/** * Tests that the default action of a controller is to render a default * view from the view engine. */ public function testRenderDefaultView() { $routerOptions = array(Config::KEY_DI => 'Vectorface\\SnappyRouter\\Di\\Di', Config::KEY_HANDLERS => array('ControllerHandler' => array(Config::KEY_CLASS => 'Vectorface\\SnappyRouter\\Handler\\ControllerHandler', Config::KEY_OPTIONS => array(Config::KEY_CONTROLLERS => array('TestController' => 'Vectorface\\SnappyRouterTests\\Controller\\TestDummyController'), ControllerHandler::KEY_VIEWS => array(ControllerHandler::KEY_VIEWS_PATH => __DIR__ . '/../Controller/Views'))))); $router = new SnappyRouter(new Config($routerOptions)); $path = '/test/default'; $response = $router->handleHttpRoute($path, array(), array(), 'GET'); $expected = file_get_contents(__DIR__ . '/../Controller/Views/test/default.twig'); $this->assertEquals($expected, $response); }