Passed
Push — master ( fae453...efb6a4 )
by Vincent
02:44
created

AssertFetchedRelationships   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 15
rs 10
1
<?php
2
3
namespace VGirol\JsonApiAssert\Laravel\Asserts;
4
5
use DMS\PHPUnitExtensions\ArraySubset\Assert as AssertArray;
6
use Illuminate\Foundation\Testing\TestResponse;
7
8
trait AssertFetchedRelationships
9
{
10
    public static function assertRelationshipsLinks(TestResponse $response, $expected, $path = null)
11
    {
12
        // Decode JSON response
13
        $json = $response->json();
14
15
        if (!is_null($path)) {
16
            $json = static::getJsonFromPath($json, $path);
17
        }
18
19
        static::assertHasLinks($json);
20
        $links = $json['links'];
21
        static::assertContainsOnlyAllowedMembers(['self', 'related'], $links);
22
        AssertArray::assertArraySubset($expected, $links);
23
    }
24
}
25