Test Failed
Pull Request — master (#96)
by Maximilian
17:24
created

SlotTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
c 0
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFirstResolutionIntentValue() 0 11 1
A testSlotMediaType() 0 5 1
A testSlottoCity() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Intent;
6
7
use MaxBeckers\AmazonAlexa\Intent\IntentValue;
8
use MaxBeckers\AmazonAlexa\Intent\Slot;
9
use PHPUnit\Framework\TestCase;
10
11
class SlotTest extends TestCase
12
{
13
    public function testSlotMediaType(): void
14
    {
15
        $json = file_get_contents(__DIR__ . '/Data/slot_media_type.json');
16
        $slot = Slot::fromAmazonRequest('MediaType', json_decode($json, true));
17
        $this->assertJsonStringEqualsJsonString($json, json_encode($slot));
18
    }
19
20
    public function testSlottoCity(): void
21
    {
22
        $json = file_get_contents(__DIR__ . '/Data/slot_to_city.json');
23
        $slot = Slot::fromAmazonRequest('toCity', json_decode($json, true));
24
        $this->assertJsonStringEqualsJsonString($json, json_encode($slot));
25
    }
26
27
    public function testGetFirstResolutionIntentValue(): void
28
    {
29
        $json = file_get_contents(__DIR__ . '/Data/slot_to_city.json');
30
        $slot = Slot::fromAmazonRequest('toCity', json_decode($json, true));
31
        $intentValue = $slot->getFirstResolutionIntentValue();
32
        $this->assertInstanceOf(IntentValue::class, $intentValue);
33
        $this->assertSame('chicago', $intentValue->name);
34
        $this->assertSame('ORD', $intentValue->id);
35
        $json = file_get_contents(__DIR__ . '/Data/slot_no_resolution.json');
36
        $slot = Slot::fromAmazonRequest('toCity', json_decode($json, true));
37
        $this->assertNull($slot->getFirstResolutionIntentValue());
38
    }
39
}
40