Completed
Pull Request — master (#23)
by
unknown
01:42
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 Smartbox\CoreBundle\Serializer\PlainTextDeserializationVisitor;
8
9
class PlainTextDeserializationVisitorFunctionalTest extends \PHPUnit\Framework\TestCase
10
{
11
    /**
12
     * Deserializer should return the same text it received, without modifications.
13
     */
14
    public function testDeserialization()
15
    {
16
        $builder = new SerializerBuilder();
17
18
        $serializer = $builder
19
            ->setDeserializationVisitor(
20
                'plain_text',
21
                new PlainTextDeserializationVisitor(new IdenticalPropertyNamingStrategy())
22
            )
23
            ->build();
24
25
        $data = 'I am a silly API that returns responses in plain text';
26
27
        $result = $serializer->deserialize($data, 'string', 'plain_text');
28
29
        $this->assertSame($data, $result, 'Visitor modified the payload, it should have kept it intact.');
30
    }
31
}
32