1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DaveRandom\LibLifxLan\Tests\Header; |
4
|
|
|
|
5
|
|
|
use DaveRandom\LibLifxLan\Header\FrameAddress; |
6
|
|
|
use DaveRandom\Network\MacAddress; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
final class FrameAddressTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
private $target; |
12
|
|
|
|
13
|
|
|
protected function setUp(): void |
14
|
|
|
{ |
15
|
|
|
$this->target = new MacAddress(0, 1, 2, 3, 4, 5); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testTargetProperty(): void |
19
|
|
|
{ |
20
|
|
|
$this->assertSame((new FrameAddress($this->target, false, false, 0))->getTarget(), $this->target); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testAckRequiredProperty(): void |
24
|
|
|
{ |
25
|
|
|
$this->assertFalse((new FrameAddress($this->target, false, false, 0))->isAckRequired()); |
26
|
|
|
$this->assertTrue((new FrameAddress($this->target, true, false, 0))->isAckRequired()); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testResponseRequiredProperty(): void |
30
|
|
|
{ |
31
|
|
|
$this->assertFalse((new FrameAddress($this->target, false, false, 0))->isResponseRequired()); |
32
|
|
|
$this->assertTrue((new FrameAddress($this->target, false, true, 0))->isResponseRequired()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testSequenceNoPropertyValidValues(): void |
36
|
|
|
{ |
37
|
|
|
foreach ([0, 42, 255] as $value) { |
38
|
|
|
$this->assertSame((new FrameAddress($this->target, false, false, $value))->getSequenceNo(), $value); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException |
44
|
|
|
*/ |
45
|
|
|
public function testSequenceNoPropertyValueTooLow(): void |
46
|
|
|
{ |
47
|
|
|
new FrameAddress($this->target, false, false, -1); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException |
52
|
|
|
*/ |
53
|
|
|
public function testSequenceNoPropertyValueTooHigh(): void |
54
|
|
|
{ |
55
|
|
|
new FrameAddress($this->target, false, false, 256); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|