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

CanFulfillResponseBodyTest::testJsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 18
rs 9.7998
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Response;
6
7
use MaxBeckers\AmazonAlexa\Response\CanFulfill\CanFulfillIntentResponse;
8
use MaxBeckers\AmazonAlexa\Response\CanFulfill\CanFulfillResponseBody;
9
use MaxBeckers\AmazonAlexa\Response\CanFulfill\CanFulfillSlot;
10
use PHPUnit\Framework\TestCase;
11
12
class CanFulfillResponseBodyTest extends TestCase
13
{
14
    public function testJsonSerialize(): void
15
    {
16
        $slot1 = CanFulfillSlot::create(CanFulfillSlot::CAN_UNDERSTAND_YES, CanFulfillSlot::CAN_FULFILL_YES);
17
        $slot2 = CanFulfillSlot::create(CanFulfillSlot::CAN_UNDERSTAND_MAYBE, CanFulfillSlot::CAN_FULFILL_YES);
18
        $slot3 = CanFulfillSlot::create(CanFulfillSlot::CAN_UNDERSTAND_NO, CanFulfillSlot::CAN_FULFILL_NO);
19
        $canFulfillIntent = CanFulfillIntentResponse::create(CanFulfillIntentResponse::CAN_FULFILL_YES, ['slot1' => $slot1, 'slot2' => $slot2]);
20
        $canFulfillIntent->addSlot('slot3', $slot3);
21
        $canFulfillResponseBody = CanFulfillResponseBody::create($canFulfillIntent);
22
        $this->assertSame(json_encode([
23
            'canFulfillIntent' => [
24
                'canFulfill' => 'YES',
25
                'slots' => [
26
                    'slot1' => ['canUnderstand' => 'YES', 'canFulfill' => 'YES'],
27
                    'slot2' => ['canUnderstand' => 'MAYBE', 'canFulfill' => 'YES'],
28
                    'slot3' => ['canUnderstand' => 'NO', 'canFulfill' => 'NO'],
29
                ],
30
            ],
31
        ]), json_encode($canFulfillResponseBody));
32
    }
33
}
34