clearData(); } public function testFetchVersionList() { $exp = new Response(['apiLevels' => ['v1-2']]); $h = new Versions; $req = new Request("GET", "/"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); $req = new Request("GET", ""); $res = $h->dispatch($req); $this->assertResponse($exp, $res); $req = new Request("GET", "/?id=1827"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); } public function testRespondToOptionsRequest() { $exp = new EmptyResponse(204, ['Allow' => "HEAD,GET"]); $h = new Versions; $req = new Request("OPTIONS", "/"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); } public function testUseIncorrectMethod() { $exp = new EmptyResponse(405, ['Allow' => "HEAD,GET"]); $h = new Versions; $req = new Request("POST", "/"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); } public function testUseIncorrectPath() { $exp = new EmptyResponse(404); $h = new Versions; $req = new Request("GET", "/ook"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); $req = new Request("OPTIONS", "/ook"); $res = $h->dispatch($req); $this->assertResponse($exp, $res); } }