ErrorWithViolationTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Unit\Model;
6
7
use Happyr\JsonApiResponseFactory\Model\ErrorWithViolation;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Validator\ConstraintViolationInterface;
10
11
/**
12
 * @author Radoje Albijanic <[email protected]>
13
 */
14
class ErrorWithViolationTest extends TestCase
15
{
16
    public function testCreate(): void
17
    {
18
        $violation = $this->getMockBuilder(ConstraintViolationInterface::class)
19
            ->getMock();
20
        $violation->method('getPropertyPath')
21
            ->willReturn('someProperty');
22
        $violation->method('getMessage')
23
            ->willReturn('someMessage');
24
25
        $error = ErrorWithViolation::create($violation, 'someTitle');
26
27
        self::assertEquals(
28
            [
29
                'status' => 400,
30
                'title' => 'someTitle',
31
                'source' => [
32
                    'parameter' => 'someProperty',
33
                    'message' => 'someMessage',
34
                ],
35
            ],
36
            $error->getErrorData()
37
        );
38
    }
39
}
40