public function testResourceIdRelationIdRequest() { $request = $this->request->withUri(new Uri('http://localhost/api/ping/1/comments/1'))->withMethod('GET'); $response = $this->app->__invoke($request, new Response()); $data = json_decode((string) $response->getBody(), true); $this->assertEquals(200, $response->getStatusCode()); $this->assertArrayHasKey('ack', $data); }
public function testDeleteUnknownUser() { $uuid = 'badfdcad-1ad5-42fb-8da6-4a2db08c6941'; $request = $this->request->withUri(new Uri(sprintf('http://localhost/api/users/%s', $uuid)))->withMethod('DELETE'); $response = $this->app->__invoke($request, new Response()); $data = json_decode((string) $response->getBody(), true); $this->assertEquals(404, $response->getStatusCode()); $this->assertEquals('application/json', $response->getHeaderLine('Content-Type')); $this->assertArrayHasKey('errors', $data); }
protected function request($uri = '', array $headers = [], array $server = []) { $request = new ServerRequest($server, [], $uri, null, 'php://temp', $headers); return $request->withUri(new Uri($uri)); }