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

SlotTest::testGetFirstResolutionIntentValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 11
rs 9.9666
cc 1
nc 1
nop 0
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