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

InvalidUrlExceptionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A providePrevious() 0 5 1
A properlyCreatesExceptionFromUrl() 0 7 2
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