Passed
Push — dev ( a54c1d...e34062 )
by Fike
02:05
created

SerializationTest::dataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace AmaTeam\ElasticSearch\Test\Suite\Acceptance\Mapping;
4
5
use AmaTeam\ElasticSearch\API\Mapping;
6
use AmaTeam\ElasticSearch\API\MappingInterface;
7
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\DocValuesParameter;
8
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\DynamicParameter;
9
use AmaTeam\ElasticSearch\Mapping\Type\Parameter\IndexParameter;
10
use AmaTeam\ElasticSearch\Mapping\Type\RootType;
11
use Codeception\Test\Unit;
12
use JMS\Serializer\SerializerBuilder;
13
use PHPUnit\Framework\Assert;
14
15
class SerializationTest extends Unit
16
{
17
    public function dataProvider()
18
    {
19
        return [
20
            [
21
                (new Mapping(RootType::ID))
22
                    ->setParameter(DynamicParameter::ID, false)
23
                    ->setProperty(
24
                        'title',
25
                        (new Mapping())
26
                            ->setParameter(DocValuesParameter::ID, false)
27
                            ->setParameter(IndexParameter::ID, false)
28
                    )
29
            ]
30
        ];
31
    }
32
33
    /**
34
     * @param MappingInterface $mapping
35
     *
36
     * @test
37
     * @dataProvider dataProvider
38
     */
39 View Code Duplication
    public function shouldSerializeAndDeserialize(MappingInterface $mapping)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $serializer = (new SerializerBuilder())->build();
42
        $serialized = $serializer->serialize($mapping, 'json');
43
        $deserialized = $serializer->deserialize($serialized, Mapping::class, 'json');
44
        Assert::assertEquals($mapping, $deserialized);
45
    }
46
}
47