Passed
Push — master ( 487089...443b76 )
by Chris
03:30
created

FrameTest::testSourceValidValues()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace DaveRandom\LibLifxLan\Tests\Header;
4
5
use DaveRandom\LibLifxLan\Header\Frame;
6
use PHPUnit\Framework\TestCase;
7
use const DaveRandom\LibLifxLan\UINT32_MAX;
1 ignored issue
show
Bug introduced by
The constant DaveRandom\LibLifxLan\UINT32_MAX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
8
use const DaveRandom\LibLifxLan\UINT32_MIN;
1 ignored issue
show
Bug introduced by
The constant DaveRandom\LibLifxLan\UINT32_MIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
9
10
class FrameTest extends TestCase
11
{
12
    public function testSizePropertyValidValues(): void
13
    {
14
        foreach ([0, 42, 65535] as $size) {
15
            $this->assertSame((new Frame($size, 0, false, false, 0, 0))->getSize(), $size);
16
        }
17
    }
18
19
    /**
20
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
21
     */
22
    public function testSizePropertyValueTooLow(): void
23
    {
24
        new Frame(-1, 0, false, false, 0, 0);
25
    }
26
27
    /**
28
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
29
     */
30
    public function testSizePropertyValueTooHigh(): void
31
    {
32
        new Frame(65536, 0, false, false, 0, 0);
33
    }
34
35
    public function testOriginPropertyValidValues(): void
36
    {
37
        foreach ([0, 1, 2, 3] as $origin) {
38
            $this->assertSame((new Frame(0, $origin, false, false, 0, 0))->getOrigin(), $origin);
39
        }
40
    }
41
42
    /**
43
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
44
     */
45
    public function testOriginPropertyValueTooLow(): void
46
    {
47
        new Frame(0, -1, false, false, 0, 0);
48
    }
49
50
    /**
51
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
52
     */
53
    public function testOriginPropertyValueTooHigh(): void
54
    {
55
        new Frame(0, 4, false, false, 0, 0);
56
    }
57
58
    public function testTaggedProperty(): void
59
    {
60
        $this->assertFalse((new Frame(0, 0, false, false, 0, 0))->isTagged());
61
        $this->assertTrue((new Frame(0, 0, true, false, 0, 0))->isTagged());
62
    }
63
64
    public function testAddressable(): void
65
    {
66
        $this->assertFalse((new Frame(0, 0, false, false, 0, 0))->isAddressable());
67
        $this->assertTrue((new Frame(0, 0, false, true, 0, 0))->isAddressable());
68
    }
69
70
    public function testProtocolNoValidValues(): void
71
    {
72
        foreach ([0, 42, 4095] as $protocolNo) {
73
            $this->assertSame((new Frame(0, 0, false, false, $protocolNo, 0))->getProtocolNo(), $protocolNo);
74
        }
75
    }
76
77
    /**
78
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
79
     */
80
    public function testProtocolNoPropertyValueTooLow(): void
81
    {
82
        new Frame(0, 0, false, false, -1, 0);
83
    }
84
85
    /**
86
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
87
     */
88
    public function testProtocolNoPropertyValueTooHigh(): void
89
    {
90
        new Frame(0, 0, false, false, 4096, 0);
91
    }
92
93
    public function testSourceValidValues(): void
94
    {
95
        foreach ([UINT32_MIN, 42, UINT32_MAX] as $source) {
96
            $this->assertSame((new Frame(0, 0, false, false, 0, $source))->getSource(), $source);
97
        }
98
    }
99
}
100