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

fromIpAddressProperlyCreatesExceptionWithPrev()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\Exception;
5
6
use Exception;
7
use PHPUnit\Framework\TestCase;
8
use Shlinkio\Shlink\Common\Exception\WrongIpException;
9
10
class WrongIpExceptionTest extends TestCase
11
{
12
    /**
13
     * @test
14
     */
15
    public function fromIpAddressProperlyCreatesExceptionWithoutPrev()
16
    {
17
        $e = WrongIpException::fromIpAddress('1.2.3.4');
18
19
        $this->assertEquals('Provided IP "1.2.3.4" is invalid', $e->getMessage());
20
        $this->assertEquals(0, $e->getCode());
21
        $this->assertNull($e->getPrevious());
22
    }
23
    /**
24
     * @test
25
     */
26
    public function fromIpAddressProperlyCreatesExceptionWithPrev()
27
    {
28
        $prev = new Exception('Previous error');
29
        $e = WrongIpException::fromIpAddress('1.2.3.4', $prev);
30
31
        $this->assertEquals('Provided IP "1.2.3.4" is invalid', $e->getMessage());
32
        $this->assertEquals(0, $e->getCode());
33
        $this->assertSame($prev, $e->getPrevious());
34
    }
35
}
36