Completed
Push — master ( 515b26...2fafcc )
by David
17s queued 12s
created

PlainTextDeserializationVisitorFunctionalTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testDeserialization() 0 17 1
1
<?php
2
3
namespace Smartbox\CoreBundle\Tests\Serializer;
4
5
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
6
use JMS\Serializer\SerializerBuilder;
7
use PHPUnit\Framework\TestCase;
8
use Smartbox\CoreBundle\Serializer\PlainTextDeserializationVisitor;
9
10
class PlainTextDeserializationVisitorFunctionalTest extends TestCase
11
{
12
    /**
13
     * Deserializer should return the same text it received, without modifications.
14
     */
15
    public function testDeserialization()
16
    {
17
        $builder = new SerializerBuilder();
18
19
        $serializer = $builder
20
            ->setDeserializationVisitor(
21
                'plain_text',
22
                new PlainTextDeserializationVisitor(new IdenticalPropertyNamingStrategy())
23
            )
24
            ->build();
25
26
        $data = 'I am a silly API that returns responses in plain text';
27
28
        $result = $serializer->deserialize($data, 'string', 'plain_text');
29
30
        $this->assertSame($data, $result, 'Visitor modified the payload, it should have kept it intact.');
31
    }
32
}
33