/** * We can map GET, POST, PUT, DELETE, OPTIONS and PATCH. HEAD calls GET. */ public function testRouteMethod() { $r = new Router(); $r->get('/basic', function () { return new Response('GET'); }); $r->post('/basic', function () { return new Response('POST'); }); $r->put('/basic', function () { return new Response('PUT'); }); $r->delete('/basic', function () { return new Response('DELETE'); }); $r->options('/basic', function () { return new Response('OPTIONS'); }); $r->patch('/basic', function () { return new Response('PATCH'); }); $req = Request::create('/basic'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('GET', $res->getContent()); $req = Request::create('/basic', 'HEAD'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('', $res->getContent()); $req = Request::create('/basic', 'POST'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('POST', $res->getContent()); $req = Request::create('/basic', 'PUT'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('PUT', $res->getContent()); $req = Request::create('/basic', 'DELETE'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('DELETE', $res->getContent()); $req = Request::create('/basic', 'OPTIONS'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('OPTIONS', $res->getContent()); $req = Request::create('/basic', 'PATCH'); $res = $r->run($req); $this->assertEquals(200, $res->getStatusCode()); $this->assertEquals('PATCH', $res->getContent()); }