Conditions | 2 |
Paths | 2 |
Total Lines | 33 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 27 | public static function assertFetchedSingleResourceResponse( |
|
25 | TestResponse $response, |
||
26 | $expected, |
||
27 | bool $strict |
||
28 | ) { |
||
29 | 27 | $response->assertStatus(200); |
|
30 | 24 | $response->assertHeader( |
|
31 | 24 | HttpHeader::HEADER_NAME, |
|
32 | 24 | HttpHeader::MEDIA_TYPE |
|
33 | ); |
||
34 | |||
35 | // Decode JSON response |
||
36 | 21 | $json = $response->json(); |
|
37 | |||
38 | // Checks response structure |
||
39 | 21 | static::assertHasValidStructure( |
|
40 | 21 | $json, |
|
41 | $strict |
||
42 | ); |
||
43 | |||
44 | // Checks data member |
||
45 | 18 | static::assertHasData($json); |
|
46 | 12 | $data = $json[Members::DATA]; |
|
47 | |||
48 | 12 | if ($data === null) { |
|
49 | 3 | return; |
|
50 | } |
||
51 | |||
52 | 9 | static::assertIsNotArrayOfObjects($data); |
|
53 | |||
54 | 6 | static::assertResourceObjectEquals( |
|
55 | 6 | $expected, |
|
56 | $data |
||
57 | ); |
||
60 |