public function testRouteResponseType() { $_SERVER['PATH_INFO'] = '/project/22'; $request = new Request(new Env(), new Route('/login', 'controller/action')); $this->assertEquals(Request::HTML, $request->response_type()); $this->assertEquals('/project/22', $request->path()); $this->assertTrue($request->is_html()); $this->assertFalse($request->is_json()); $this->assertFalse($request->is_xml()); $_SERVER['PATH_INFO'] = '/project/23.json'; $request = new Request(new Env(), new Route('/project/23', 'controller/action')); $this->assertEquals(Request::JSON, $request->response_type()); $this->assertEquals('/project/23', $request->path()); $this->assertFalse($request->is_html()); $this->assertTrue($request->is_json()); $this->assertFalse($request->is_xml()); $_SERVER['PATH_INFO'] = '/project/24.html'; $request = new Request(new Env(), new Route('/login', 'controller/action')); $this->assertEquals(Request::HTML, $request->response_type()); $this->assertEquals('/project/24', $request->path()); $this->assertTrue($request->is_html()); $this->assertFalse($request->is_json()); $this->assertFalse($request->is_xml()); $_SERVER['PATH_INFO'] = '/project/25.xml'; $request = new Request(new Env(), new Route('/profile', 'controller/action')); $this->assertEquals(Request::XML, $request->response_type()); $this->assertEquals('/project/25', $request->path()); $this->assertFalse($request->is_html()); $this->assertFalse($request->is_json()); $this->assertTrue($request->is_xml()); $_SERVER['PATH_INFO'] = '/project/25.xml'; $_POST['_format'] = 'json'; $request = new Request(new Env(), new Route('/profile', 'controller/action')); $this->assertEquals(Request::JSON, $request->response_type()); $this->assertEquals('/project/25', $request->path()); $this->assertFalse($request->is_html()); $this->assertTrue($request->is_json()); $this->assertFalse($request->is_xml()); }