| Total Complexity | 6 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait AssertResource |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Asserts that a resource object correspond to a given model. |
||
| 13 | * |
||
| 14 | * @param array $expected |
||
| 15 | * @param array $json |
||
| 16 | */ |
||
| 17 | public static function assertResourceObjectEquals($expected, $json) |
||
| 18 | { |
||
| 19 | PHPUnit::assertEquals($expected, $json); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Asserts that an array of resource objects is equal to a given collection (same values and same order). |
||
| 24 | * |
||
| 25 | * @param array $expected |
||
| 26 | * @param array $json |
||
| 27 | */ |
||
| 28 | public static function assertResourceCollectionEquals($expected, $json) |
||
| 29 | { |
||
| 30 | static::assertIsArrayOfObjects($expected); |
||
| 31 | PHPUnit::assertEquals(count($expected), count($json)); |
||
| 32 | |||
| 33 | $index = 0; |
||
| 34 | foreach ($expected as $resource) { |
||
| 35 | static::assertResourceObjectEquals($resource, $json[$index]); |
||
| 36 | $index++; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Asserts that an array of resource objects contains a given collection. |
||
| 42 | * |
||
| 43 | * @param array $expected |
||
| 44 | * @param array $json |
||
| 45 | */ |
||
| 46 | public static function assertResourceCollectionContains($expected, $json) |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 |