Passed
Push — master ( a53d55...43aca1 )
by Maximilian
03:50
created

SetFocusCommandTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 22
dl 0
loc 57
rs 10
c 1
b 0
f 1
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithComponentId() 0 7 1
A testJsonSerializeWithNullValue() 0 7 1
A testConstructorWithDefaultParameters() 0 5 1
A testJsonSerializeWithComponentId() 0 9 1
A testJsonSerializeWithEmptyString() 0 7 1
A testTypeConstant() 0 3 1
A testImplementsJsonSerializable() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\APL\StandardCommand;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand\SetFocusCommand;
8
use PHPUnit\Framework\TestCase;
9
10
class SetFocusCommandTest extends TestCase
11
{
12
    public function testConstructorWithComponentId(): void
13
    {
14
        $componentId = 'myComponent';
15
16
        $command = new SetFocusCommand($componentId);
17
18
        $this->assertSame($componentId, $command->componentId);
19
    }
20
21
    public function testConstructorWithDefaultParameters(): void
22
    {
23
        $command = new SetFocusCommand();
24
25
        $this->assertNull($command->componentId);
26
    }
27
28
    public function testJsonSerializeWithComponentId(): void
29
    {
30
        $componentId = 'testComponent';
31
32
        $command = new SetFocusCommand($componentId);
33
        $result = $command->jsonSerialize();
34
35
        $this->assertSame(SetFocusCommand::TYPE, $result['type']);
36
        $this->assertSame($componentId, $result['componentId']);
37
    }
38
39
    public function testJsonSerializeWithNullValue(): void
40
    {
41
        $command = new SetFocusCommand();
42
        $result = $command->jsonSerialize();
43
44
        $this->assertSame(SetFocusCommand::TYPE, $result['type']);
45
        $this->assertArrayNotHasKey('componentId', $result);
46
    }
47
48
    public function testJsonSerializeWithEmptyString(): void
49
    {
50
        $command = new SetFocusCommand('');
51
        $result = $command->jsonSerialize();
52
53
        $this->assertSame(SetFocusCommand::TYPE, $result['type']);
54
        $this->assertSame('', $result['componentId']);
55
    }
56
57
    public function testImplementsJsonSerializable(): void
58
    {
59
        $command = new SetFocusCommand();
60
61
        $this->assertInstanceOf(\JsonSerializable::class, $command);
62
    }
63
64
    public function testTypeConstant(): void
65
    {
66
        $this->assertSame('SetFocus', SetFocusCommand::TYPE);
67
    }
68
}
69