'/cakes']); $request = $request->withAttribute('params', [ 'controller' => 'Cakes', 'action' => 'index', 'plugin' => null, 'pass' => [] ]); $path = dirname(dirname(__DIR__)); $app = $this->getMockForAbstractClass('Cake\Http\BaseApplication', [$path]); $result = $app($request, $response, $next); $this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $result); $this->assertEquals('Hello Jane', '' . $result->getBody()); } /** * Ensure that Router::$initialized is toggled even if the routes * file fails. This prevents the routes file from being re-parsed * during the error handling process. * * @return void */ public function testRouteHookInitializesRouterOnError() { $app = $this->getMockForAbstractClass( 'Cake\Http\BaseApplication', [TEST_APP . 'invalid_routes' . DS] ); $builder = Router::createRouteBuilder('/'); try { $app->routes($builder); $this->fail('invalid_routes/routes.php file should raise an error.'); } catch (\InvalidArgumentException $e) { $this->assertTrue(Router::$initialized, 'Should be toggled to prevent duplicate route errors'); $this->assertContains('route class', $e->getMessage()); } } }