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

properlyCreatesExceptionFromUrl()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 1
dl 0
loc 7
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\InvalidUrlException;
9
use Throwable;
10
11
class InvalidUrlExceptionTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @dataProvider providePrevious
16
     */
17
    public function properlyCreatesExceptionFromUrl(?Throwable $prev)
18
    {
19
        $e = InvalidUrlException::fromUrl('http://the_url.com', $prev);
20
21
        $this->assertEquals('Provided URL "http://the_url.com" is not an existing and valid URL', $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