for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace VGirol\JsonApiAssert\Asserts\Content;
use PHPUnit\Framework\Assert as PHPUnit;
trait AssertResource
{
/**
* Asserts that a resource object correspond to a given model.
*
* @param array $expected
* @param array $json
*/
public static function assertResourceObjectEquals($expected, $json)
PHPUnit::assertEquals($expected, $json);
}
* Asserts that an array of resource objects is equal to a given collection (same values and same order).
public static function assertResourceCollectionEquals($expected, $json)
static::assertIsArrayOfObjects($expected);
PHPUnit::assertEquals(count($expected), count($json));
$index = 0;
foreach ($expected as $resource) {
static::assertResourceObjectEquals($resource, $json[$index]);
$index++;
* Asserts that an array of resource objects contains a given collection.
public static function assertResourceCollectionContains($expected, $json)
if (!static::isArrayOfObjects($expected)) {
$expected = [$expected];
PHPUnit::assertContains($resource, $json);