1
<?php
2

3
namespace Nuwave\Lighthouse\Testing;
4

5
use Illuminate\Support\Arr;
6
use Nuwave\Lighthouse\Exceptions\ValidationException;
7

8
/**
9
 * Because we can not have non-mixin methods in mixin classes.
10
 *
11
 * @see \Nuwave\Lighthouse\Testing\TestResponseMixin
12
 */
13
class TestResponseUtils
14
{
15
    /**
16
     * @param  \Illuminate\Testing\TestResponse  $response
17
     */
18 1
    public static function extractValidationErrors($response): ?array
19
    {
20 1
        $errors = $response->json('errors') ?? [];
21

22 1
        return Arr::first(
23 1
            $errors,
24
            function (array $error): bool {
25 1
                return Arr::get($error, 'extensions.category') === ValidationException::CATEGORY;
26
            }
27
        );
28
    }
29
}

Read our documentation on viewing source code .

Loading