Completed
Push — master ( 67e465...aa77c9 )
by Alejandro
13s queued 10s
created

properlyCreatesExceptionFromNotFoundShortCode()   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
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Core\Exception;
5
6
use Exception;
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Core\Exception\InvalidShortCodeException;
9
use Throwable;
10
11
class InvalidShortCodeExceptionTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @dataProvider providePrevious
16
     */
17
    public function properlyCreatesExceptionFromCharset(?Throwable $prev)
18
    {
19
        $e = InvalidShortCodeException::fromCharset('abc123', 'def456', $prev);
20
21
        $this->assertEquals('Provided short code "abc123" does not match the char set "def456"', $e->getMessage());
22
        $this->assertEquals($prev !== null ? $prev->getCode() : -1, $e->getCode());
23
        $this->assertEquals($prev, $e->getPrevious());
24
    }
25
26
    public function providePrevious(): array
27
    {
28
        return [
29
            [null],
30
            [new Exception('Previos error', 10)],
31
        ];
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function properlyCreatesExceptionFromNotFoundShortCode()
38
    {
39
        $e = InvalidShortCodeException::fromNotFoundShortCode('abc123');
40
41
        $this->assertEquals('Provided short code "abc123" does not belong to a short URL', $e->getMessage());
42
    }
43
}
44