Test Failed
Push — master ( ea2523...459f4e )
by Pablo
36s
created

TcpPortValueObjectTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 3
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A itShouldReturnTcpPort() 0 8 1
A invalidTcpPortProvider() 0 10 1
A itShouldThrowsException() 0 6 1
1
<?php
2
3
namespace PhpValueObjects\Tests\Network;
4
5
use PhpValueObjects\Network\Exception\InvalidTcpPortException;
6
use PhpValueObjects\Tests\BaseUnitTestCase;
7
8
class TcpPortValueObjectTest extends BaseUnitTestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itShouldReturnTcpPort()
14
    {
15
        $portNumber = $this->faker()->numberBetween(0, 65535);
16
17
        $tcpPort = new TcpPortValueObject($portNumber);
18
19
        $this->assertSame($portNumber, $tcpPort->value());
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function invalidTcpPortProvider()
26
    {
27
        return [
28
            [null],
29
            [11362.0],
30
            [$this->faker()->randomFloat()],
31
            [$this->faker()->numberBetween(65536)],
32
            [-$this->faker()->numberBetween()],
33
        ];
34
    }
35
36
    /**
37
     * @test
38
     * @dataProvider invalidTcpPortProvider
39
     */
40
    public function itShouldThrowsException($data)
41
    {
42
        $this->expectException(InvalidTcpPortException::class);
43
44
        new TcpPortValueObject($data);
45
    }
46
}
47