public function testRouting405() { $request = new CLIRequest("/introduction", 'example.com', 'POST'); $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request)); $this->injector->share($request); $renderCallable = $this->injector->execute('Tier\\Bridge\\JigFastRouter::routeRequest'); $body = TierApp::executeExecutable($renderCallable, $this->injector); $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body); /** @var $body \Room11\HTTP\Body\HtmlBody */ $html = $body->getData(); $this->assertContains("Method not allowed for route.", $html); $this->assertEquals(405, $body->getStatusCode()); }
public function testRouting405() { $request = new CLIRequest("/introduction", 'example.com', 'POST'); $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request)); $this->injector->share($request); $router = $this->injector->make('Tier\\Bridge\\FastRouter'); $fn404ErrorPage = function () { return new TextBody("Route not found.", 404); }; $fn405ErrorPage = function () { return new TextBody("Method not allowed for route.", 405); }; $result = $router->routeRequest($request, $fn404ErrorPage, $fn405ErrorPage); $body = TierApp::executeExecutable($result, $this->injector); $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body); /** @var $body \Room11\HTTP\Body\HtmlBody */ $html = $body->getData(); $this->assertContains("Method not allowed for route.", $html); $this->assertEquals(405, $body->getStatusCode()); }