Passed
Push — master ( 4b2c1a...a53d55 )
by Maximilian
02:53
created

IntentTest::testWithResolutions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
rs 10
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\Intent;
8
use MaxBeckers\AmazonAlexa\Intent\Slot;
9
use PHPUnit\Framework\TestCase;
10
11
class IntentTest extends TestCase
12
{
13
    public function testWithoutResolutions(): void
14
    {
15
        $json = file_get_contents(__DIR__ . '/Data/intent_without_resolutions.json');
16
        $intent = Intent::fromAmazonRequest(json_decode($json, true));
17
        $this->assertJsonStringEqualsJsonString($json, json_encode($intent));
18
    }
19
20
    public function testWithResolutions(): void
21
    {
22
        $json = file_get_contents(__DIR__ . '/Data/intent_resolution.json');
23
        $intent = Intent::fromAmazonRequest(json_decode($json, true));
24
        $this->assertJsonStringEqualsJsonString($json, json_encode($intent));
25
    }
26
27
    public function testGetResolutionByName(): void
28
    {
29
        $json = file_get_contents(__DIR__ . '/Data/intent_without_resolutions.json');
30
        $intent = Intent::fromAmazonRequest(json_decode($json, true));
31
        $slot = $intent->getSlotByName('Age');
32
        $this->assertInstanceOf(Slot::class, $slot);
33
        $this->assertSame('Age', $slot->name);
34
        $slot = $intent->getSlotByName('age');
35
        $this->assertNull($slot);
36
        $slot = $intent->getSlotByName('Gender');
37
        $this->assertInstanceOf(Slot::class, $slot);
38
        $this->assertSame('Gender', $slot->name);
39
    }
40
}
41