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

testDeserialization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 1
nc 1
nop 0
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