|
2 | 2 |
|
3 | 3 | namespace App\Tests\ApiPlatform; |
4 | 4 |
|
5 | | -use Symfony\Component\HttpFoundation\Response; |
| 5 | +use App\Tests\ApiPlatform\Trait\GetEntitiesTestTrait; |
6 | 6 |
|
| 7 | +/** |
| 8 | + * Test that we can call the API. |
| 9 | + */ |
7 | 10 | class EventsTest extends AbstractApiTestCase |
8 | 11 | { |
9 | | - public function testGetEvents(): void |
10 | | - { |
11 | | - static::createClient() |
12 | | - ->request('GET', '/api/v2/events'); |
| 12 | + use GetEntitiesTestTrait; |
13 | 13 |
|
14 | | - $this->assertResponseStatusCodeSame(Response::HTTP_UNAUTHORIZED); |
15 | | - |
16 | | - $response = static::createAuthenticatedClient() |
17 | | - ->request('GET', '/api/v2/events'); |
18 | | - |
19 | | - $this->assertResponseStatusCodeSame(Response::HTTP_OK); |
20 | | - $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); |
21 | | - $this->assertJson($response->getContent()); |
22 | | - |
23 | | - $data = $response->toArray(); |
24 | | - $this->assertArrayHasKey('hydra:member', $data); |
25 | | - $this->assertCount(2, $data['hydra:member']); |
26 | | - |
27 | | - $response = static::createAuthenticatedClient() |
28 | | - ->request('GET', '/api/v2/events?'.http_build_query(['publicAccess' => 'true'])); |
29 | | - |
30 | | - $this->assertResponseStatusCodeSame(Response::HTTP_OK); |
31 | | - $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); |
32 | | - $this->assertJson($response->getContent()); |
33 | | - |
34 | | - $data = $response->toArray(); |
35 | | - $this->assertArrayHasKey('hydra:member', $data); |
36 | | - $this->assertCount(1, $data['hydra:member']); |
37 | | - |
38 | | - $response = static::createAuthenticatedClient() |
39 | | - ->request('GET', '/api/v2/events?'.http_build_query(['publicAccess' => 'false'])); |
40 | | - |
41 | | - $this->assertResponseStatusCodeSame(Response::HTTP_OK); |
42 | | - $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); |
43 | | - $this->assertJson($response->getContent()); |
44 | | - |
45 | | - $data = $response->toArray(); |
46 | | - $this->assertArrayHasKey('hydra:member', $data); |
47 | | - $this->assertCount(1, $data['hydra:member']); |
48 | | - } |
| 14 | + protected static string $requestPath = '/api/v2/events'; |
49 | 15 | } |
0 commit comments