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

EchoResponseTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testPayloadPropertyValidValues() 0 3 1
A testPayloadPropertyValueTooShort() 0 3 1
A testTypeIdProperty() 0 3 1
A setUp() 0 3 1
A testPayloadPropertyValueTooLong() 0 3 1
A testWireSizeProperty() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\LibLifxLan\Tests\Messages\Device\Responses;
4
5
use DaveRandom\LibLifxLan\Messages\Device\Responses\EchoResponse;
6
use PHPUnit\Framework\TestCase;
7
8
final class EchoResponseTest extends TestCase
9
{
10
    private $payload;
11
12
    protected function setUp(): void
13
    {
14
        $this->payload = \str_pad('', 64, 'test');
15
    }
16
17
    public function testPayloadPropertyValidValues(): void
18
    {
19
        $this->assertSame((new EchoResponse($this->payload))->getPayload(), $this->payload);
20
    }
21
22
    /**
23
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
24
     */
25
    public function testPayloadPropertyValueTooShort(): void
26
    {
27
        new EchoResponse(\str_pad('', 63, 'test'));
28
    }
29
30
    /**
31
     * @expectedException \DaveRandom\LibLifxLan\Exceptions\InvalidValueException
32
     */
33
    public function testPayloadPropertyValueTooLong(): void
34
    {
35
        new EchoResponse(\str_pad('', 65, 'test'));
36
    }
37
38
    public function testTypeIdProperty(): void
39
    {
40
        $this->assertSame((new EchoResponse($this->payload))->getTypeId(), EchoResponse::MESSAGE_TYPE_ID);
41
    }
42
43
    public function testWireSizeProperty(): void
44
    {
45
        $this->assertSame((new EchoResponse($this->payload))->getWireSize(), EchoResponse::WIRE_SIZE);
46
    }
47
}
48