Completed
Push — master ( 4f6cc8...658d1d )
by Pablo
03:09
created

Ipv4ValueObjectTest::itShouldThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace PhpValueObjects\Tests\Network;
4
5
use PhpValueObjects\Network\Exception\InvalidIpv4Exception;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8 View Code Duplication
class Ipv4ValueObjectTest extends BaseUnitTestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnIpv4Address()
14
    {
15
16
        $ipAddress = $this->faker()->ipv4;
17
18
        $ipv4 = new Ipv4ValueObject($ipAddress);
19
20
        $this->assertSame($ipAddress, $ipv4->value());
21
        $this->assertSame($ipAddress, $ipv4->__toString());
22
    }
23
24
    /**
25
     * @return array
26
     */
27
    public function invalidIpv4AddressProvider()
28
    {
29
        return [
30
            [null],
31
            [$this->faker()->numberBetween()],
32
            [$this->faker()->ipv6]
33
        ];
34
    }
35
36
    /**
37
     * @test
38
     * @dataProvider invalidIpv4AddressProvider
39
     */
40
    public function itShouldThrowsException($data)
41
    {
42
        $this->expectException(InvalidIpv4Exception::class);
43
44
        new Ipv4ValueObject($data);
45
    }
46
}
47