Passed
Pull Request — master (#13)
by
unknown
02:44
created

itShouldExtendApiServiceError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ElevenLabs\Api\Service\Tests\Exception;
6
7
use ElevenLabs\Api\Service\Exception\ApiServiceError;
8
use ElevenLabs\Api\Service\Exception\ConstraintViolations;
9
use ElevenLabs\Api\Validator\ConstraintViolation;
10
use PHPUnit\Framework\MockObject\MockObject;
11
use PHPUnit\Framework\TestCase;
12
13
/**
14
 * Class ConstraintViolationsTest.
15
 */
16
class ConstraintViolationsTest extends TestCase
17
{
18
    /** @test */
19
    public function itShouldExtendApiServiceError()
20
    {
21
        $exception = new ConstraintViolations([]);
22
23
        $this->assertInstanceOf(ApiServiceError::class, $exception);
24
    }
25
26
    /** @test */
27
    public function itShouldProvideTheListOfViolations()
28
    {
29
        /** @var ConstraintViolation|MockObject $violation */
30
        $violation = $this->createMock(ConstraintViolation::class);
31
        $violation->expects($this->once())->method('getProperty')->willReturn('foo');
32
        $violation->expects($this->once())->method('getMessage')->willReturn('bar is not a string');
33
        $violation->expects($this->once())->method('getConstraint')->willReturn('');
34
        $violation->expects($this->once())->method('getLocation')->willReturn('foo');
35
36
        $exception = new ConstraintViolations([$violation]);
37
38
        $this->assertSame([$violation], $exception->getViolations());
39
    }
40
}
41