createRequestBuilder() ->setMethod('GET') ->setUri('/api/events') ->setAcceptType('application/json') ->addServerParameter('HTTP_X-AUTH-TOKEN', UserFixtures::ADMIN_USER_REFERENCE) ->request(); $response = $this->client->getResponse(); $this->assertTrue($response->headers->contains('Content-Type', 'application/json'), 'the "Content-Type" header is "' . $response->headers->get('Content-Type') . '"' // optional message shown on failure ); $this->assertEquals(200, $response->getStatusCode(), 'Status code was ' . $response->getStatusCode() . ' but expected 200: ' . $response->getContent()); $data = json_decode($response->getContent()); // Expect two events $this->assertEquals(2, count($data)); } }