Completed
Push — master ( 11b317...37df4d )
by Lucas
09:27
created

ModuleControllerTest   B

Complexity

Total Complexity 17

Size/Duplication

Total Lines 676
Duplicated Lines 7.54 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 2
dl 51
loc 676
rs 7.3038
c 0
b 0
f 0

16 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
B testGetModuleWithPaging() 0 25 1
A testFindAllEmptyCollection() 14 14 1
B testGetModuleWithKeyAndUseId() 0 31 1
B testFindByAppRef() 0 24 1
B findByAppRefProvider() 25 25 1
B testExtrefOperators() 0 28 1
B dataExtrefOperators() 0 190 1
B testPostModule() 0 31 1
A testPostInvalidInteger() 0 22 1
B testPutModule() 0 46 1
A testDeleteModule() 0 22 1
B testExtRefTransformation() 0 26 1
B testExtReferenceValidation() 0 31 2
A testGetModuleCollectionSchemaInformationFormat() 0 20 1
A encodeRqlString() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * functional test for /core/module
4
 */
5
6
namespace Graviton\CoreBundle\Tests\Controller;
7
8
use Graviton\TestBundle\Test\RestTestCase;
9
use Symfony\Component\HttpFoundation\Response;
10
11
/**
12
 * Basic functional test for /core/module.
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 ModuleControllerTest extends RestTestCase
19
{
20
    /**
21
     * @const complete content type string expected on a resouce
22
     */
23
    const CONTENT_TYPE = 'application/json; charset=UTF-8; profile=http://localhost/schema/core/module/item';
24
25
    /**
26
     * @const corresponding vendorized schema mime type
27
     */
28
    const COLLECTION_TYPE = 'application/json; charset=UTF-8; profile=http://localhost/schema/core/module/collection';
29
30
    /**
31
     * setup client and load fixtures
32
     *
33
     * @return void
34
     */
35
    public function setUp()
36
    {
37
        $this->loadFixtures(
38
            array(
39
                'Graviton\I18nBundle\DataFixtures\MongoDB\LoadLanguageData',
40
                'GravitonDyn\ModuleBundle\DataFixtures\MongoDB\LoadModuleData'
41
            ),
42
            null,
43
            'doctrine_mongodb'
44
        );
45
    }
46
47
    /**
48
     * test if we can get list of modules paged
49
     *
50
     * @return void
51
     */
52
    public function testGetModuleWithPaging()
53
    {
54
        $client = static::createRestClient();
55
        $client->request('GET', '/core/module/?limit(1)');
56
        $response = $client->getResponse();
57
58
        $this->assertEquals(1, count($client->getResults()));
59
60
        $this->assertContains(
61
            '<http://localhost/core/module/?limit(1)>; rel="self"',
62
            explode(',', $response->headers->get('Link'))
63
        );
64
65
        $this->assertContains(
66
            '<http://localhost/core/module/?limit(1%2C1)>; rel="next"',
67
            $response->headers->get('Link')
68
        );
69
70
        $this->assertContains(
71
            '<http://localhost/core/module/?limit(1%2C5)>; rel="last"',
72
            $response->headers->get('Link')
73
        );
74
75
        $this->assertEquals('http://localhost/core/app/admin', $client->getResults()[0]->app->{'$ref'});
76
    }
77
78
    /**
79
     * check for empty collections when no fixtures are loaded
80
     *
81
     * @return void
82
     */
83 View Code Duplication
    public function testFindAllEmptyCollection()
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...
84
    {
85
        // reset fixtures since we already have some from setUp
86
        $this->loadFixtures(array(), null, 'doctrine_mongodb');
87
        $client = static::createRestClient();
88
        $client->request('GET', '/core/module/');
89
90
        $response = $client->getResponse();
91
        $results = $client->getResults();
92
93
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
94
95
        $this->assertEquals(array(), $results);
96
    }
97
98
    /**
99
     * test if we can get an module first by key and then its id (id is dynamic)
100
     *
101
     * @return void
102
     */
103
    public function testGetModuleWithKeyAndUseId()
104
    {
105
        $client = static::createRestClient();
106
        $client->request('GET', '/core/module/?eq(key,investment)');
107
        $response = $client->getResponse();
108
        $results = $client->getResults();
109
110
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
111
        $this->assertEquals('investment', $results[0]->key);
112
        $this->assertEquals(1, count($results));
113
114
        // get entry by id
115
        $moduleId = $results[0]->id;
116
117
        $client = static::createRestClient();
118
        $client->request('GET', '/core/module/'.$moduleId);
119
        $response = $client->getResponse();
120
        $results = $client->getResults();
121
122
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
123
        $this->assertEquals($moduleId, $results->id);
124
        $this->assertEquals('investment', $results->key);
125
        $this->assertEquals('/module/investment', $results->path);
126
        $this->assertEquals(2, $results->order);
127
128
        $this->assertContains(
129
            '<http://localhost/core/module/'.$moduleId.'>; rel="self"',
130
            explode(',', $response->headers->get('Link'))
131
        );
132
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
133
    }
134
135
    /**
136
     * test finding of modules by ref
137
     *
138
     * @dataProvider findByAppRefProvider
139
     *
140
     * @param string  $ref   which reference to search in
141
     * @param mixed   $url   ref to search for
142
     * @param integer $count number of results to expect
143
     *
144
     * @return void
145
     */
146
    public function testFindByAppRef($ref, $url, $count)
147
    {
148
        $this->loadFixtures(
149
            [
150
                'Graviton\I18nBundle\DataFixtures\MongoDB\LoadLanguageData',
151
                'GravitonDyn\ModuleBundle\DataFixtures\MongoDB\LoadModuleData',
152
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadAppData',
153
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadProductData',
154
            ],
155
            null,
156
            'doctrine_mongodb'
157
        );
158
159
        $url = sprintf(
160
            '/core/module/?%s=%s',
161
            $this->encodeRqlString($ref),
162
            $this->encodeRqlString($url)
163
        );
164
165
        $client = static::createRestClient();
166
        $client->request('GET', $url);
167
        $results = $client->getResults();
168
        $this->assertCount($count, $results);
169
    }
170
171
    /**
172
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array<string|integer>>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
173
     */
174 View Code Duplication
    public function findByAppRefProvider()
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...
175
    {
176
        return [
177
            'find all tablet records' => [
178
                'app.$ref',
179
                'http://localhost/core/app/tablet',
180
                5
181
            ],
182
            'find a linked record when searching for ref' => [
183
                'app.$ref',
184
                'http://localhost/core/app/admin',
185
                1
186
            ],
187
            'find nothing when searching for inextistant (and unlinked) ref' => [
188
                'app.$ref',
189
                'http://localhost/core/app/inexistant',
190
                0
191
            ],
192
            'return nothing when searching with incomplete ref' => [
193
                'app.$ref',
194
                'http://localhost/core/app',
195
                0
196
            ],
197
        ];
198
    }
199
200
    /**
201
     * Apply RQL operators to extref fields
202
     *
203
     * @dataProvider dataExtrefOperators
204
     *
205
     * @param string $rqlQuery    RQL query
206
     * @param array  $expectedIds Expected found IDs
207
     *
208
     * @return void
209
     */
210
    public function testExtrefOperators($rqlQuery, array $expectedIds)
211
    {
212
        $this->loadFixtures(
213
            [
214
                'Graviton\I18nBundle\DataFixtures\MongoDB\LoadLanguageData',
215
                'GravitonDyn\ModuleBundle\DataFixtures\MongoDB\LoadModuleData',
216
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadAppData',
217
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadProductData',
218
            ],
219
            null,
220
            'doctrine_mongodb'
221
        );
222
223
        $client = static::createRestClient();
224
        $client->request('GET', '/core/module/?'.$rqlQuery);
225
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
226
227
        $foundIds = array_map(
228
            function ($item) {
229
                return $item->id;
230
            },
231
            $client->getResults()
232
        );
233
234
        sort($foundIds);
235
        sort($expectedIds);
236
        $this->assertEquals($expectedIds, $foundIds);
237
    }
238
239
    /**
240
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,array<string|array>>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
241
     */
242
    public function dataExtrefOperators()
243
    {
244
        $tabletIds = [
245
            'tablet-realEstate',
246
            'tablet-investment',
247
            'tablet-retirement',
248
            'tablet-requisition',
249
            'tablet-payAndSave',
250
        ];
251
        $adminIds = [
252
            'admin-AdminRef',
253
        ];
254
255
        return [
256
            '== tablet' => [
257
                sprintf(
258
                    '%s=%s',
259
                    $this->encodeRqlString('app.$ref'),
260
                    $this->encodeRqlString('http://localhost/core/app/tablet')
261
                ),
262
                $tabletIds,
263
            ],
264
            '!= tablet' => [
265
                sprintf(
266
                    '%s!=%s',
267
                    $this->encodeRqlString('app.$ref'),
268
                    $this->encodeRqlString('http://localhost/core/app/tablet')
269
                ),
270
                $adminIds,
271
            ],
272
            '> tablet' => [
273
                sprintf(
274
                    '%s>%s',
275
                    $this->encodeRqlString('app.$ref'),
276
                    $this->encodeRqlString('http://localhost/core/app/tablet')
277
                ),
278
                [],
279
            ],
280
            '< tablet' => [
281
                sprintf(
282
                    '%s<%s',
283
                    $this->encodeRqlString('app.$ref'),
284
                    $this->encodeRqlString('http://localhost/core/app/tablet')
285
                ),
286
                $adminIds,
287
            ],
288
            '>= tablet' => [
289
                sprintf(
290
                    '%s>=%s',
291
                    $this->encodeRqlString('app.$ref'),
292
                    $this->encodeRqlString('http://localhost/core/app/tablet')
293
                ),
294
                $tabletIds,
295
            ],
296
            '<= tablet' => [
297
                sprintf(
298
                    '%s<=%s',
299
                    $this->encodeRqlString('app.$ref'),
300
                    $this->encodeRqlString('http://localhost/core/app/tablet')
301
                ),
302
                array_merge($tabletIds, $adminIds),
303
            ],
304
            '=in= tablet' => [
305
                sprintf(
306
                    '%s=in=(%s)',
307
                    $this->encodeRqlString('app.$ref'),
308
                    $this->encodeRqlString('http://localhost/core/app/tablet')
309
                ),
310
                $tabletIds,
311
            ],
312
            '=out= tablet' => [
313
                sprintf(
314
                    '%s=out=(%s)',
315
                    $this->encodeRqlString('app.$ref'),
316
                    $this->encodeRqlString('http://localhost/core/app/tablet')
317
                ),
318
                $adminIds,
319
            ],
320
321
            '> admin' => [
322
                sprintf(
323
                    '%s>%s',
324
                    $this->encodeRqlString('app.$ref'),
325
                    $this->encodeRqlString('http://localhost/core/app/admin')
326
                ),
327
                $tabletIds,
328
            ],
329
            '< admin' => [
330
                sprintf(
331
                    '%s<%s',
332
                    $this->encodeRqlString('app.$ref'),
333
                    $this->encodeRqlString('http://localhost/core/app/admin')
334
                ),
335
                [],
336
            ],
337
            '>= admin' => [
338
                sprintf(
339
                    '%s>=%s',
340
                    $this->encodeRqlString('app.$ref'),
341
                    $this->encodeRqlString('http://localhost/core/app/admin')
342
                ),
343
                array_merge($tabletIds, $adminIds),
344
            ],
345
            '<= admin' => [
346
                sprintf(
347
                    '%s<=%s',
348
                    $this->encodeRqlString('app.$ref'),
349
                    $this->encodeRqlString('http://localhost/core/app/admin')
350
                ),
351
                $adminIds,
352
            ],
353
            '=in= admin' => [
354
                sprintf(
355
                    '%s=in=(%s)',
356
                    $this->encodeRqlString('app.$ref'),
357
                    $this->encodeRqlString('http://localhost/core/app/admin')
358
                ),
359
                $adminIds,
360
            ],
361
            '=out= admin' => [
362
                sprintf(
363
                    '%s=out=(%s)',
364
                    $this->encodeRqlString('app.$ref'),
365
                    $this->encodeRqlString('http://localhost/core/app/admin')
366
                ),
367
                $tabletIds,
368
            ],
369
370
            '=in= admin, tablet' => [
371
                sprintf(
372
                    '%s=in=(%s,%s)',
373
                    $this->encodeRqlString('app.$ref'),
374
                    $this->encodeRqlString('http://localhost/core/app/admin'),
375
                    $this->encodeRqlString('http://localhost/core/app/tablet')
376
                ),
377
                array_merge($adminIds, $tabletIds),
378
            ],
379
            '=out= admin, tablet' => [
380
                sprintf(
381
                    '%s=out=(%s,%s)',
382
                    $this->encodeRqlString('app.$ref'),
383
                    $this->encodeRqlString('http://localhost/core/app/admin'),
384
                    $this->encodeRqlString('http://localhost/core/app/tablet')
385
                ),
386
                [],
387
            ],
388
389
            '== admin || == tablet' => [
390
                sprintf(
391
                    '(%s==%s|%s==%s)',
392
                    $this->encodeRqlString('app.$ref'),
393
                    $this->encodeRqlString('http://localhost/core/app/admin'),
394
                    $this->encodeRqlString('app.$ref'),
395
                    $this->encodeRqlString('http://localhost/core/app/tablet')
396
                ),
397
                array_merge($adminIds, $tabletIds),
398
            ],
399
            '== admin && == tablet' => [
400
                sprintf(
401
                    '(%s==%s&%s==%s)',
402
                    $this->encodeRqlString('app.$ref'),
403
                    $this->encodeRqlString('http://localhost/core/app/admin'),
404
                    $this->encodeRqlString('app.$ref'),
405
                    $this->encodeRqlString('http://localhost/core/app/tablet')
406
                ),
407
                [],
408
            ],
409
410
            '== admin || some logic' => [
411
                sprintf(
412
                    'or(eq(%s,%s),and(eq(id,%s),eq(id,%s)))',
413
                    $this->encodeRqlString('app.$ref'),
414
                    $this->encodeRqlString('http://localhost/core/app/admin'),
415
                    $this->encodeRqlString('not-existing-id-1'),
416
                    $this->encodeRqlString('not-existing-id-2')
417
                ),
418
                $adminIds,
419
            ],
420
            '== tablet && some logic' => [
421
                sprintf(
422
                    'and(eq(%s,%s),or(eq(id,%s),eq(id,%s)))',
423
                    $this->encodeRqlString('app.$ref'),
424
                    $this->encodeRqlString('http://localhost/core/app/tablet'),
425
                    $this->encodeRqlString($tabletIds[0]),
426
                    $this->encodeRqlString($tabletIds[1])
427
                ),
428
                [$tabletIds[0], $tabletIds[1]]
429
            ],
430
        ];
431
    }
432
433
    /**
434
     * test if we can create a module through POST
435
     *
436
     * @return void
437
     */
438
    public function testPostModule()
439
    {
440
        $testModule = new \stdClass;
441
        $testModule->key = 'test';
442
        $testModule->app = new \stdClass;
443
        $testModule->app->{'$ref'} = 'http://localhost/core/app/testapp';
444
        $testModule->name = new \stdClass;
445
        $testModule->name->en = 'Name';
446
        $testModule->path = '/test/test';
447
        $testModule->order = 50;
448
449
        $client = static::createRestClient();
450
        $client->post('/core/module/', $testModule);
451
        $response = $client->getResponse();
452
        $this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode());
453
454
        $client = static::createRestClient();
455
        $client->request('GET', $response->headers->get('Location'));
456
        $response = $client->getResponse();
457
        $results = $client->getResults();
458
459
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
460
461
        $this->assertEquals('http://localhost/core/app/testapp', $results->app->{'$ref'});
462
        $this->assertEquals(50, $results->order);
463
464
        $this->assertContains(
465
            '<http://localhost/core/module/'.$results->id.'>; rel="self"',
466
            explode(',', $response->headers->get('Link'))
467
        );
468
    }
469
470
    /**
471
     * test validation error for int types
472
     *
473
     * @return void
474
     */
475
    public function testPostInvalidInteger()
476
    {
477
        $testModule = new \stdClass;
478
        $testModule->key = 'test';
479
        $testModule->app = new \stdClass;
480
        $testModule->app->{'$ref'} = 'http://localhost/core/app/testapp';
481
        $testModule->name = new \stdClass;
482
        $testModule->name->en = 'Name';
483
        $testModule->path = '/test/test';
484
        $testModule->order = 'clearly a string';
485
486
        $client = static::createRestClient();
487
        $client->post('/core/module', $testModule);
488
489
        $response = $client->getResponse();
490
        $results = $client->getResults();
491
492
        $this->assertEquals(400, $response->getStatusCode());
493
494
        $this->assertContains('order', $results[0]->propertyPath);
495
        $this->assertEquals('This value is not valid.', $results[0]->message);
496
    }
497
498
    /**
499
     * test updating module
500
     *
501
     * @return void
502
     */
503
    public function testPutModule()
504
    {
505
        // get id first..
506
        $client = static::createRestClient();
507
        $client->request('GET', '/core/module/?eq(key,investment)');
508
        $response = $client->getResponse();
509
        $results = $client->getResults();
510
511
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
512
        $this->assertEquals('investment', $results[0]->key);
513
        $this->assertEquals(1, count($results));
514
515
        // get entry by id
516
        $moduleId = $results[0]->id;
517
518
        $putModule = new \stdClass();
519
        $putModule->id = $moduleId;
520
        $putModule->key = 'test';
521
        $putModule->app = new \stdClass;
522
        $putModule->app->{'$ref'} = 'http://localhost/core/app/test';
523
        $putModule->name = new \stdClass;
524
        $putModule->name->en = 'testerle';
525
        $putModule->path = '/test/test';
526
        $putModule->order = 500;
527
528
        $client = static::createRestClient();
529
        $client->put('/core/module/'.$moduleId, $putModule);
530
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
531
532
        $client = static::createRestClient();
533
        $client->request('GET', '/core/module/'.$moduleId);
534
        $response = $client->getResponse();
535
        $results = $client->getResults();
536
537
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
538
539
        $this->assertEquals($moduleId, $results->id);
540
        $this->assertEquals('http://localhost/core/app/test', $results->app->{'$ref'});
541
        $this->assertEquals(500, $results->order);
542
543
        $this->assertContains(
544
            '<http://localhost/core/module/'.$moduleId.'>; rel="self"',
545
            explode(',', $response->headers->get('Link'))
546
        );
547
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
548
    }
549
550
    /**
551
     * test deleting a module
552
     *
553
     * @return void
554
     */
555
    public function testDeleteModule()
556
    {
557
        // get id first..
558
        $client = static::createRestClient();
559
        $client->request('GET', '/core/module/?eq(key,investment)');
560
        $results = $client->getResults();
561
562
        // get entry by id
563
        $moduleId = $results[0]->id;
564
565
        $client = static::createRestClient();
566
        $client->request('DELETE', '/core/module/'.$moduleId);
567
568
        $response = $client->getResponse();
569
570
        $this->assertEquals(204, $response->getStatusCode());
571
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
572
        $this->assertEmpty($response->getContent());
573
574
        $client->request('GET', '/core/module/'.$moduleId);
575
        $this->assertEquals(404, $client->getResponse()->getStatusCode());
576
    }
577
578
    /**
579
     * Test extref transformation
580
     *
581
     * @return void
582
     */
583
    public function testExtRefTransformation()
584
    {
585
        $client = static::createRestClient();
586
587
        $client->request('GET', '/core/module/?eq(key,investment)');
588
        $results = $client->getResults();
589
        $this->assertCount(1, $results);
590
591
        $module = $results[0];
592
        $this->assertEquals('investment', $module->key);
593
        $this->assertEquals('http://localhost/core/app/tablet', $module->app->{'$ref'});
594
595
        $module->app->{'$ref'} = 'http://localhost/core/app/admin';
596
597
        $client = static::createRestClient();
598
        $client->put('/core/module/'.$module->id, $module);
599
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
600
601
602
        $client = static::createRestClient();
603
        $client->request('GET', '/core/module/'.$module->id);
604
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
605
606
        $module = $client->getResults();
607
        $this->assertEquals('http://localhost/core/app/admin', $module->app->{'$ref'});
608
    }
609
610
    /**
611
     * Test extref validation
612
     *
613
     * @return void
614
     */
615
    public function testExtReferenceValidation()
616
    {
617
        $client = static::createRestClient();
618
        $client->request('GET', '/core/module/?eq(key,investment)');
619
        $this->assertCount(1, $client->getResults());
620
621
        $module = $client->getResults()[0];
622
623
        $urls = [
624
            'http://localhost',
625
            'http://localhost/core',
626
            'http://localhost/core/app',
627
            'http://localhost/core/noapp/admin',
628
        ];
629
        foreach ($urls as $url) {
630
            $module->app->{'$ref'} = $url;
631
632
            $client = static::createRestClient();
633
            $client->put('/core/module/'.$module->id, $module);
634
            $this->assertEquals(Response::HTTP_BAD_REQUEST, $client->getResponse()->getStatusCode());
635
            $this->assertEquals(
636
                [
637
                    (object) [
638
                        'propertyPath' => 'children[app].children[ref]',
639
                        'message' => sprintf('URL "%s" is not a valid ext reference.', $url),
640
                    ],
641
                ],
642
                $client->getResults()
643
            );
644
        }
645
    }
646
647
    /**
648
     * test getting collection schema.
649
     * i avoid retesting everything (covered in /core/app), this test only
650
     * asserts translatable & extref representation
651
     *
652
     * @return void
653
     */
654
    public function testGetModuleCollectionSchemaInformationFormat()
655
    {
656
        $client = static::createRestClient();
657
658
        $client->request('GET', '/schema/core/module/collection');
659
        $results = $client->getResults();
660
661
        $this->assertEquals('object', $results->items->properties->app->type);
662
        $this->assertEquals('string', $results->items->properties->app->properties->{'$ref'}->type);
663
        $this->assertEquals('extref', $results->items->properties->app->properties->{'$ref'}->format);
664
665
        $service = $results->items->properties->service;
666
        $this->assertEquals('array', $service->type);
667
        $this->assertEquals('object', $service->items->properties->name->type);
668
        $this->assertEquals('string', $service->items->properties->name->properties->en->type);
669
        $this->assertEquals('object', $service->items->properties->description->type);
670
        $this->assertEquals('string', $service->items->properties->description->properties->en->type);
671
        $this->assertEquals('object', $service->items->properties->service->type);
672
        $this->assertEquals('string', $service->items->properties->service->properties->{'$ref'}->type);
673
    }
674
675
    /**
676
     * Encode RQL string
677
     *
678
     * @param string $value Value
679
     * @return string
680
     */
681 View Code Duplication
    private function encodeRqlString($value)
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...
682
    {
683
        return strtr(
684
            rawurlencode($value),
685
            [
686
                '-' => '%2D',
687
                '_' => '%5F',
688
                '.' => '%2E',
689
                '~' => '%7E',
690
            ]
691
        );
692
    }
693
}
694