AssertJsonapi::assertJsonapiObjectEquals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiAssert\Asserts\Content;
6
7
use PHPUnit\Framework\Assert as PHPUnit;
8
use VGirol\JsonApiAssert\Messages;
9
10
/**
11
 * This trait adds the ability to test jsonapi object content.
12
 */
13
trait AssertJsonapi
14
{
15
    /**
16
     * Asserts that a jsonapi object equals an expected array.
17
     *
18
     * @link https://jsonapi.org/format/#document-jsonapi-object
19
     *
20
     * @param array $expected The expected jsonapi object
21
     * @param array $json     The jsonapi object to test
22
     *
23
     * @return void
24
     * @throws \PHPUnit\Framework\AssertionFailedError
25
     */
26 6
    public static function assertJsonapiObjectEquals($expected, $json): void
27
    {
28 6
        PHPUnit::assertSame(
29 6
            $expected,
30 6
            $json,
31 6
            sprintf(Messages::JSONAPI_OBJECT_NOT_EQUAL, var_export($json, true), var_export($expected, true))
32
        );
33 3
    }
34
}
35