Completed
Push — feature/EVO-8123-rql-select-up... ( 4f51a0...52598c )
by
unknown
09:49
created

testRqlSelectionOnNestedDouble()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
/**
3
 * SerializerSelectExclusionStrategyTest class file
4
 */
5
6
namespace Graviton\CoreBundle\Tests\Controller;
7
8
use Graviton\TestBundle\Test\RestTestCase;
9
use Symfony\Component\HttpFoundation\Response;
10
use GravitonDyn\TestCasePrimitiveArrayBundle\DataFixtures\MongoDB\LoadTestCasePrimitiveArrayData;
11
use GravitonDyn\TestCaseNullExtrefBundle\DataFixtures\MongoDB\LoadTestCaseNullExtrefData;
12
13
/**
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class SerializerSelectExclusionStrategyTest extends RestTestCase
19
{
20
21
    /**
22
     * load fixtures (in this case we can reuse fixtures from other tests)
23
     *
24
     * @return void
25
     */
26
    public function setUp()
27
    {
28
        if (!class_exists(LoadTestCasePrimitiveArrayData::class)) {
29
            $this->markTestSkipped('TestCasePrimitiveArray definition is not loaded');
30
        }
31
        if (!class_exists(LoadTestCaseNullExtrefData::class)) {
32
            $this->markTestSkipped('TestCaseNullExtref definition is not loaded');
33
        }
34
35
        $this->loadFixtures(
36
            [LoadTestCasePrimitiveArrayData::class, LoadTestCaseNullExtrefData::class],
37
            null,
38
            'doctrine_mongodb'
39
        );
40
    }
41
42
    /**
43
     * Test testRqlSelectionOnArrays testing the correct serialization of nested arrays
44
     *
45
     * @return void
46
     */
47 View Code Duplication
    public function testRqlSelectionOnArrays()
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...
48
    {
49
        $expectedResult = json_decode(
50
            file_get_contents(dirname(__FILE__).'/../resources/serializer-exclusion-array.json'),
51
            false
52
        );
53
54
        $client = static::createRestClient();
55
        $client->request(
56
            'GET',
57
            '/testcase/primitivearray/testdata?select(hash.strarray,arrayhash.intarray,arrayhash.hasharray)'
58
        );
59
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
60
        $this->assertEquals($expectedResult, $client->getResults());
61
    }
62
63
    /**
64
     * Test testRqlSelectionOnNested testing the correct serialization of deeply nested values
65
     *
66
     * @return void
67
     */
68 View Code Duplication
    public function testRqlSelectionOnNested()
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...
69
    {
70
        $expectedResult = json_decode(
71
            file_get_contents(dirname(__FILE__).'/../resources/serializer-exclusion-nested.json'),
72
            false
73
        );
74
75
        $client = static::createRestClient();
76
        $client->request(
77
            'GET',
78
            '/testcase/nullextref/testdata?select(requiredExtref,requiredExtrefDeep.deep.deep,optionalExtrefDeep)'
79
        );
80
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
81
        $this->assertEquals($expectedResult, $client->getResults());
82
    }
83
84
    /**
85
     * Test testRqlSelectionOnNested testing the correct serialization of deeply nested values
86
     *
87
     * @return void
88
     */
89
    public function testRqlSelectionOnNestedDouble()
90
    {
91
        $expectedResult = json_decode(
92
            file_get_contents(dirname(__FILE__).'/../resources/serializer-exclusion-nested-double.json'),
93
            false
94
        );
95
96
        $client = static::createRestClient();
97
        $client->request(
98
            'GET',
99
            '/testcase/nullextref/testdata?select(optionalExtrefDeep.deep.deep.deep,requiredExtrefDeep.deep.deep)'
100
        );
101
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
102
        $this->assertEquals($expectedResult, $client->getResults());
103
    }
104
}
105