|
@@ 74-83 (lines=10) @@
|
| 71 |
|
* |
| 72 |
|
* @throws PHPUnit_Framework_AssertionFailedError |
| 73 |
|
*/ |
| 74 |
|
public function assertJsonApiIdentifierCollection(array $array, $count = null) |
| 75 |
|
{ |
| 76 |
|
$this->assertArrayHasKey('data', $array, 'No data key for collection'); |
| 77 |
|
|
| 78 |
|
foreach ($array['data'] as $identifier) { |
| 79 |
|
$this->assertArrayHasAll(['type', 'id'], (array) $identifier); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
$this->assertCount($count, $array['data'], 'Incorrect object count returned in collection'); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
/** |
| 86 |
|
* Assert that an array contains a valid JSON API resource object collection. |
|
@@ 93-104 (lines=12) @@
|
| 90 |
|
* |
| 91 |
|
* @throws PHPUnit_Framework_AssertionFailedError |
| 92 |
|
*/ |
| 93 |
|
public function assertJsonApiObjectCollection(array $array, $count = null) |
| 94 |
|
{ |
| 95 |
|
$this->assertArrayHasKey('data', $array, 'No data key for collection'); |
| 96 |
|
|
| 97 |
|
foreach ($array['data'] as $object) { |
| 98 |
|
$this->assertArrayHasAll(['type', 'id', 'attributes'], (array) $object); |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
if (!is_null($count)) { |
| 102 |
|
$this->assertCount($count, $array['data'], 'Incorrect object count returned in collection'); |
| 103 |
|
} |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|