Completed
Push — master ( 77bf97...70e8e5 )
by Avtandil
02:17
created

ErrorResourceTest::it_should_transform_array()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 16
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Unit\Http\Resources;
6
7
use Illuminate\Http\JsonResponse;
8
use Illuminate\Http\Request;
9
use Longman\LaravelLodash\Http\Resources\ErrorResource;
10
use Tests\Unit\TestCase;
11
12
use function app;
13
14 View Code Duplication
class ErrorResourceTest extends TestCase
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /** @test */
17
    public function it_should_transform_array(): void
18
    {
19
        $resource = new ErrorResource([
20
            'aa'  => 1,
21
            'aa2' => 2,
22
            'aa3' => 3,
23
        ]);
24
25
        $request = app(Request::class);
26
        $response = $resource->additional(['custom' => '1'])->toResponse($request);
27
28
        $expected = '{"errors":{"general":{"aa":1,"aa2":2,"aa3":3}},"custom":"1"}';
29
30
        $this->assertInstanceOf(JsonResponse::class, $response);
31
        $this->assertSame($expected, $response->content());
32
    }
33
}
34