|
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
|
|
|
|