ReplaceTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 15
c 1
b 0
f 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreateWithReplaceBehaviour() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Test\Response\Directives\Dialog\UpdateDynamicEntities;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\Dialog\Entity\Type;
8
use MaxBeckers\AmazonAlexa\Response\Directives\Dialog\Entity\TypeValue;
9
use MaxBeckers\AmazonAlexa\Response\Directives\Dialog\UpdateDynamicEntities\Replace;
10
use PHPUnit\Framework\TestCase;
11
12
class ReplaceTest extends TestCase
13
{
14
    public function testCreateWithReplaceBehaviour(): void
15
    {
16
        $type = Type::create('AirportSlotType', [
17
            TypeValue::create('LGA', 'LaGuardia Airport', ['New York']),
18
        ]);
19
20
        /** @var Replace $directive */
21
        $directive = Replace::create();
22
        $directive->addType($type);
23
        $this->assertIsArray($directive->types);
24
        $this->assertSame([$type], $directive->types);
25
        $this->assertSame('Dialog.UpdateDynamicEntities', $directive->type);
26
        $this->assertSame('REPLACE', $directive->updateBehavior);
27
28
        $json = \file_get_contents(__DIR__ . '/../../../../Response/Data/directive_dialog_update_dynamic_entities_replace.json');
29
        $expected = \json_decode($json);
30
31
        $this->assertSame($expected->type, $directive->type);
32
        $this->assertSame($expected->updateBehavior, $directive->updateBehavior);
33
        $this->assertSame(\count($expected->types), \count($directive->types));
34
        $this->assertSame(\json_encode($expected->types), \json_encode($directive->types));
35
    }
36
}
37