Completed
Push — feature/EVO-5751-searchindex-t... ( cbfd94 )
by
unknown
10:02
created

ModuleControllerTest::testSearchIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
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, generate search indexes separately
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
        $this->setVerbosityLevel(1);
47
        $this->isDecorated(true);
48
        $this->runCommand('graviton:generate:build-indexes', [], true);
49
    }
50
51
    /**
52
     * testing the search in search index, combined with a select (RQL)
53
     *
54
     * @return void
55
     */
56
    public function testSearchIndex()
57
    {
58
        $client = static::createRestClient();
59
        $client->request('GET', '/core/module/?search(module)&select(key)');
60
        $this->assertEquals('retirement', $client->getResults()[0]->key);
61
        $this->assertEquals('realEstate', $client->getResults()[1]->key);
62
        $this->assertEquals('investment', $client->getResults()[2]->key);
63
        $this->assertEquals('requisition', $client->getResults()[3]->key);
64
        $this->assertEquals('payAndSave', $client->getResults()[4]->key);
65
66
        $client = static::createRestClient();
67
        $client->request('GET', '/core/module/?search(AdminRef)&select(key)');
68
        $this->assertEquals('AdminRef', $client->getResults()[0]->key);
69
    }
70
71
    /**
72
     * test if we can get list of modules paged
73
     *
74
     * @return void
75
     */
76
    public function testGetModuleWithPaging()
77
    {
78
        $client = static::createRestClient();
79
        $client->request('GET', '/core/module/?limit(1)');
80
        $response = $client->getResponse();
81
82
        $this->assertEquals(1, count($client->getResults()));
83
84
        $this->assertContains(
85
            '<http://localhost/core/module/?limit(1)>; rel="self"',
86
            explode(',', $response->headers->get('Link'))
87
        );
88
89
        $this->assertContains(
90
            '<http://localhost/core/module/?limit(1%2C1)>; rel="next"',
91
            $response->headers->get('Link')
92
        );
93
94
        $this->assertContains(
95
            '<http://localhost/core/module/?limit(1%2C5)>; rel="last"',
96
            $response->headers->get('Link')
97
        );
98
99
        $this->assertEquals('http://localhost/core/app/admin', $client->getResults()[0]->app->{'$ref'});
100
    }
101
102
    /**
103
     * check for empty collections when no fixtures are loaded
104
     *
105
     * @return void
106
     */
107 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...
108
    {
109
        // reset fixtures since we already have some from setUp
110
        $this->loadFixtures(array(), null, 'doctrine_mongodb');
111
        $client = static::createRestClient();
112
        $client->request('GET', '/core/module/');
113
114
        $response = $client->getResponse();
115
        $results = $client->getResults();
116
117
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
118
119
        $this->assertEquals(array(), $results);
120
    }
121
122
    /**
123
     * test if we can get an module first by key and then its id (id is dynamic)
124
     *
125
     * @return void
126
     */
127
    public function testGetModuleWithKeyAndUseId()
128
    {
129
        $client = static::createRestClient();
130
        $client->request('GET', '/core/module/?eq(key,investment)');
131
        $response = $client->getResponse();
132
        $results = $client->getResults();
133
134
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
135
        $this->assertEquals('investment', $results[0]->key);
136
        $this->assertEquals(1, count($results));
137
138
        // get entry by id
139
        $moduleId = $results[0]->id;
140
141
        $client = static::createRestClient();
142
        $client->request('GET', '/core/module/'.$moduleId);
143
        $response = $client->getResponse();
144
        $results = $client->getResults();
145
146
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
147
        $this->assertEquals($moduleId, $results->id);
148
        $this->assertEquals('investment', $results->key);
149
        $this->assertEquals('/module/investment', $results->path);
150
        $this->assertEquals(2, $results->order);
151
152
        $this->assertContains(
153
            '<http://localhost/core/module/'.$moduleId.'>; rel="self"',
154
            explode(',', $response->headers->get('Link'))
155
        );
156
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
157
    }
158
159
    /**
160
     * test finding of modules by ref
161
     *
162
     * @dataProvider findByAppRefProvider
163
     *
164
     * @param string  $ref   which reference to search in
165
     * @param mixed   $url   ref to search for
166
     * @param integer $count number of results to expect
167
     *
168
     * @return void
169
     */
170
    public function testFindByAppRef($ref, $url, $count)
171
    {
172
        $this->loadFixtures(
173
            [
174
                'Graviton\I18nBundle\DataFixtures\MongoDB\LoadLanguageData',
175
                'GravitonDyn\ModuleBundle\DataFixtures\MongoDB\LoadModuleData',
176
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadAppData',
177
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadProductData',
178
            ],
179
            null,
180
            'doctrine_mongodb'
181
        );
182
183
        $url = sprintf(
184
            '/core/module/?%s=%s',
185
            $this->encodeRqlString($ref),
186
            $this->encodeRqlString($url)
187
        );
188
189
        $client = static::createRestClient();
190
        $client->request('GET', $url);
191
        $results = $client->getResults();
192
        $this->assertCount($count, $results);
193
    }
194
195
    /**
196
     * @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...
197
     */
198 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...
199
    {
200
        return [
201
            'find all tablet records' => [
202
                'app.$ref',
203
                'http://localhost/core/app/tablet',
204
                5
205
            ],
206
            'find a linked record when searching for ref' => [
207
                'app.$ref',
208
                'http://localhost/core/app/admin',
209
                1
210
            ],
211
            'find nothing when searching for inextistant (and unlinked) ref' => [
212
                'app.$ref',
213
                'http://localhost/core/app/inexistant',
214
                0
215
            ],
216
            'return nothing when searching with incomplete ref' => [
217
                'app.$ref',
218
                'http://localhost/core/app',
219
                0
220
            ],
221
        ];
222
    }
223
224
    /**
225
     * Apply RQL operators to extref fields
226
     *
227
     * @dataProvider dataExtrefOperators
228
     *
229
     * @param string $rqlQuery    RQL query
230
     * @param array  $expectedIds Expected found IDs
231
     *
232
     * @return void
233
     */
234
    public function testExtrefOperators($rqlQuery, array $expectedIds)
235
    {
236
        $this->loadFixtures(
237
            [
238
                'Graviton\I18nBundle\DataFixtures\MongoDB\LoadLanguageData',
239
                'GravitonDyn\ModuleBundle\DataFixtures\MongoDB\LoadModuleData',
240
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadAppData',
241
                'Graviton\CoreBundle\DataFixtures\MongoDB\LoadProductData',
242
            ],
243
            null,
244
            'doctrine_mongodb'
245
        );
246
247
        $client = static::createRestClient();
248
        $client->request('GET', '/core/module/?'.$rqlQuery);
249
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
250
251
        $foundIds = array_map(
252
            function ($item) {
253
                return $item->id;
254
            },
255
            $client->getResults()
256
        );
257
258
        sort($foundIds);
259
        sort($expectedIds);
260
        $this->assertEquals($expectedIds, $foundIds);
261
    }
262
263
    /**
264
     * @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...
265
     */
266
    public function dataExtrefOperators()
267
    {
268
        $tabletIds = [
269
            'tablet-realEstate',
270
            'tablet-investment',
271
            'tablet-retirement',
272
            'tablet-requisition',
273
            'tablet-payAndSave',
274
        ];
275
        $adminIds = [
276
            'admin-AdminRef',
277
        ];
278
279
        return [
280
            '== tablet' => [
281
                sprintf(
282
                    '%s=%s',
283
                    $this->encodeRqlString('app.$ref'),
284
                    $this->encodeRqlString('http://localhost/core/app/tablet')
285
                ),
286
                $tabletIds,
287
            ],
288
            '!= tablet' => [
289
                sprintf(
290
                    '%s!=%s',
291
                    $this->encodeRqlString('app.$ref'),
292
                    $this->encodeRqlString('http://localhost/core/app/tablet')
293
                ),
294
                $adminIds,
295
            ],
296
            '> tablet' => [
297
                sprintf(
298
                    '%s>%s',
299
                    $this->encodeRqlString('app.$ref'),
300
                    $this->encodeRqlString('http://localhost/core/app/tablet')
301
                ),
302
                [],
303
            ],
304
            '< tablet' => [
305
                sprintf(
306
                    '%s<%s',
307
                    $this->encodeRqlString('app.$ref'),
308
                    $this->encodeRqlString('http://localhost/core/app/tablet')
309
                ),
310
                $adminIds,
311
            ],
312
            '>= tablet' => [
313
                sprintf(
314
                    '%s>=%s',
315
                    $this->encodeRqlString('app.$ref'),
316
                    $this->encodeRqlString('http://localhost/core/app/tablet')
317
                ),
318
                $tabletIds,
319
            ],
320
            '<= tablet' => [
321
                sprintf(
322
                    '%s<=%s',
323
                    $this->encodeRqlString('app.$ref'),
324
                    $this->encodeRqlString('http://localhost/core/app/tablet')
325
                ),
326
                array_merge($tabletIds, $adminIds),
327
            ],
328
            '=in= tablet' => [
329
                sprintf(
330
                    '%s=in=(%s)',
331
                    $this->encodeRqlString('app.$ref'),
332
                    $this->encodeRqlString('http://localhost/core/app/tablet')
333
                ),
334
                $tabletIds,
335
            ],
336
            '=out= tablet' => [
337
                sprintf(
338
                    '%s=out=(%s)',
339
                    $this->encodeRqlString('app.$ref'),
340
                    $this->encodeRqlString('http://localhost/core/app/tablet')
341
                ),
342
                $adminIds,
343
            ],
344
345
            '> admin' => [
346
                sprintf(
347
                    '%s>%s',
348
                    $this->encodeRqlString('app.$ref'),
349
                    $this->encodeRqlString('http://localhost/core/app/admin')
350
                ),
351
                $tabletIds,
352
            ],
353
            '< admin' => [
354
                sprintf(
355
                    '%s<%s',
356
                    $this->encodeRqlString('app.$ref'),
357
                    $this->encodeRqlString('http://localhost/core/app/admin')
358
                ),
359
                [],
360
            ],
361
            '>= admin' => [
362
                sprintf(
363
                    '%s>=%s',
364
                    $this->encodeRqlString('app.$ref'),
365
                    $this->encodeRqlString('http://localhost/core/app/admin')
366
                ),
367
                array_merge($tabletIds, $adminIds),
368
            ],
369
            '<= admin' => [
370
                sprintf(
371
                    '%s<=%s',
372
                    $this->encodeRqlString('app.$ref'),
373
                    $this->encodeRqlString('http://localhost/core/app/admin')
374
                ),
375
                $adminIds,
376
            ],
377
            '=in= admin' => [
378
                sprintf(
379
                    '%s=in=(%s)',
380
                    $this->encodeRqlString('app.$ref'),
381
                    $this->encodeRqlString('http://localhost/core/app/admin')
382
                ),
383
                $adminIds,
384
            ],
385
            '=out= admin' => [
386
                sprintf(
387
                    '%s=out=(%s)',
388
                    $this->encodeRqlString('app.$ref'),
389
                    $this->encodeRqlString('http://localhost/core/app/admin')
390
                ),
391
                $tabletIds,
392
            ],
393
394
            '=in= admin, tablet' => [
395
                sprintf(
396
                    '%s=in=(%s,%s)',
397
                    $this->encodeRqlString('app.$ref'),
398
                    $this->encodeRqlString('http://localhost/core/app/admin'),
399
                    $this->encodeRqlString('http://localhost/core/app/tablet')
400
                ),
401
                array_merge($adminIds, $tabletIds),
402
            ],
403
            '=out= admin, tablet' => [
404
                sprintf(
405
                    '%s=out=(%s,%s)',
406
                    $this->encodeRqlString('app.$ref'),
407
                    $this->encodeRqlString('http://localhost/core/app/admin'),
408
                    $this->encodeRqlString('http://localhost/core/app/tablet')
409
                ),
410
                [],
411
            ],
412
413
            '== admin || == tablet' => [
414
                sprintf(
415
                    '(%s==%s|%s==%s)',
416
                    $this->encodeRqlString('app.$ref'),
417
                    $this->encodeRqlString('http://localhost/core/app/admin'),
418
                    $this->encodeRqlString('app.$ref'),
419
                    $this->encodeRqlString('http://localhost/core/app/tablet')
420
                ),
421
                array_merge($adminIds, $tabletIds),
422
            ],
423
            '== admin && == tablet' => [
424
                sprintf(
425
                    '(%s==%s&%s==%s)',
426
                    $this->encodeRqlString('app.$ref'),
427
                    $this->encodeRqlString('http://localhost/core/app/admin'),
428
                    $this->encodeRqlString('app.$ref'),
429
                    $this->encodeRqlString('http://localhost/core/app/tablet')
430
                ),
431
                [],
432
            ],
433
434
            '== admin || some logic' => [
435
                sprintf(
436
                    'or(eq(%s,%s),and(eq(id,%s),eq(id,%s)))',
437
                    $this->encodeRqlString('app.$ref'),
438
                    $this->encodeRqlString('http://localhost/core/app/admin'),
439
                    $this->encodeRqlString('not-existing-id-1'),
440
                    $this->encodeRqlString('not-existing-id-2')
441
                ),
442
                $adminIds,
443
            ],
444
            '== tablet && some logic' => [
445
                sprintf(
446
                    'and(eq(%s,%s),or(eq(id,%s),eq(id,%s)))',
447
                    $this->encodeRqlString('app.$ref'),
448
                    $this->encodeRqlString('http://localhost/core/app/tablet'),
449
                    $this->encodeRqlString($tabletIds[0]),
450
                    $this->encodeRqlString($tabletIds[1])
451
                ),
452
                [$tabletIds[0], $tabletIds[1]]
453
            ],
454
        ];
455
    }
456
457
    /**
458
     * test if we can create a module through POST
459
     *
460
     * @return void
461
     */
462
    public function testPostModule()
463
    {
464
        $testModule = new \stdClass;
465
        $testModule->key = 'test';
466
        $testModule->app = new \stdClass;
467
        $testModule->app->{'$ref'} = 'http://localhost/core/app/testapp';
468
        $testModule->name = new \stdClass;
469
        $testModule->name->en = 'Name';
470
        $testModule->path = '/test/test';
471
        $testModule->order = 50;
472
473
        $client = static::createRestClient();
474
        $client->post('/core/module/', $testModule);
475
        $response = $client->getResponse();
476
        $this->assertEquals(Response::HTTP_CREATED, $response->getStatusCode());
477
478
        $client = static::createRestClient();
479
        $client->request('GET', $response->headers->get('Location'));
480
        $response = $client->getResponse();
481
        $results = $client->getResults();
482
483
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
484
485
        $this->assertEquals('http://localhost/core/app/testapp', $results->app->{'$ref'});
486
        $this->assertEquals(50, $results->order);
487
488
        $this->assertContains(
489
            '<http://localhost/core/module/'.$results->id.'>; rel="self"',
490
            explode(',', $response->headers->get('Link'))
491
        );
492
    }
493
494
    /**
495
     * test validation error for int types
496
     *
497
     * @return void
498
     */
499
    public function testPostInvalidInteger()
500
    {
501
        $testModule = new \stdClass;
502
        $testModule->key = 'test';
503
        $testModule->app = new \stdClass;
504
        $testModule->app->{'$ref'} = 'http://localhost/core/app/testapp';
505
        $testModule->name = new \stdClass;
506
        $testModule->name->en = 'Name';
507
        $testModule->path = '/test/test';
508
        $testModule->order = 'clearly a string';
509
510
        $client = static::createRestClient();
511
        $client->post('/core/module', $testModule);
512
513
        $response = $client->getResponse();
514
        $results = $client->getResults();
515
516
        $this->assertEquals(400, $response->getStatusCode());
517
518
        $this->assertContains('order', $results[0]->propertyPath);
519
        $this->assertEquals('String value found, but an integer is required', $results[0]->message);
520
    }
521
522
    /**
523
     * test updating module
524
     *
525
     * @return void
526
     */
527
    public function testPutModule()
528
    {
529
        // get id first..
530
        $client = static::createRestClient();
531
        $client->request('GET', '/core/module/?eq(key,investment)');
532
        $response = $client->getResponse();
533
        $results = $client->getResults();
534
535
        $this->assertResponseContentType(self::COLLECTION_TYPE, $response);
536
        $this->assertEquals('investment', $results[0]->key);
537
        $this->assertEquals(1, count($results));
538
539
        // get entry by id
540
        $moduleId = $results[0]->id;
541
542
        $putModule = new \stdClass();
543
        $putModule->id = $moduleId;
544
        $putModule->key = 'test';
545
        $putModule->app = new \stdClass;
546
        $putModule->app->{'$ref'} = 'http://localhost/core/app/test';
547
        $putModule->name = new \stdClass;
548
        $putModule->name->en = 'testerle';
549
        $putModule->path = '/test/test';
550
        $putModule->order = 500;
551
552
        $client = static::createRestClient();
553
        $client->put('/core/module/'.$moduleId, $putModule);
554
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
555
556
        $client = static::createRestClient();
557
        $client->request('GET', '/core/module/'.$moduleId);
558
        $response = $client->getResponse();
559
        $results = $client->getResults();
560
561
        $this->assertResponseContentType(self::CONTENT_TYPE, $response);
562
563
        $this->assertEquals($moduleId, $results->id);
564
        $this->assertEquals('http://localhost/core/app/test', $results->app->{'$ref'});
565
        $this->assertEquals(500, $results->order);
566
567
        $this->assertContains(
568
            '<http://localhost/core/module/'.$moduleId.'>; rel="self"',
569
            explode(',', $response->headers->get('Link'))
570
        );
571
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
572
    }
573
574
    /**
575
     * test deleting a module
576
     *
577
     * @return void
578
     */
579
    public function testDeleteModule()
580
    {
581
        // get id first..
582
        $client = static::createRestClient();
583
        $client->request('GET', '/core/module/?eq(key,investment)');
584
        $results = $client->getResults();
585
586
        // get entry by id
587
        $moduleId = $results[0]->id;
588
589
        $client = static::createRestClient();
590
        $client->request('DELETE', '/core/module/'.$moduleId);
591
592
        $response = $client->getResponse();
593
594
        $this->assertEquals(204, $response->getStatusCode());
595
        $this->assertEquals('*', $response->headers->get('Access-Control-Allow-Origin'));
596
        $this->assertEmpty($response->getContent());
597
598
        $client->request('GET', '/core/module/'.$moduleId);
599
        $this->assertEquals(404, $client->getResponse()->getStatusCode());
600
    }
601
602
    /**
603
     * Test extref transformation
604
     *
605
     * @return void
606
     */
607
    public function testExtRefTransformation()
608
    {
609
        $client = static::createRestClient();
610
611
        $client->request('GET', '/core/module/?eq(key,investment)');
612
        $results = $client->getResults();
613
        $this->assertCount(1, $results);
614
615
        $module = $results[0];
616
        $this->assertEquals('investment', $module->key);
617
        $this->assertEquals('http://localhost/core/app/tablet', $module->app->{'$ref'});
618
619
        $module->app->{'$ref'} = 'http://localhost/core/app/admin';
620
621
        $client = static::createRestClient();
622
        $client->put('/core/module/'.$module->id, $module);
623
        $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode());
624
625
626
        $client = static::createRestClient();
627
        $client->request('GET', '/core/module/'.$module->id);
628
        $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode());
629
630
        $module = $client->getResults();
631
        $this->assertEquals('http://localhost/core/app/admin', $module->app->{'$ref'});
632
    }
633
634
    /**
635
     * Test extref validation
636
     *
637
     * @return void
638
     */
639
    public function testExtReferenceValidation()
640
    {
641
        $client = static::createRestClient();
642
        $client->request('GET', '/core/module/?eq(key,investment)');
643
        $this->assertCount(1, $client->getResults());
644
645
        $module = $client->getResults()[0];
646
647
        $urls = [
648
            'http://localhost',
649
            'http://localhost/core',
650
            'http://localhost/core/app',
651
            'http://localhost/core/noapp/admin',
652
        ];
653
        foreach ($urls as $url) {
654
            $module->app->{'$ref'} = $url;
655
656
            $client = static::createRestClient();
657
            $client->put('/core/module/'.$module->id, $module);
658
            $this->assertEquals(Response::HTTP_BAD_REQUEST, $client->getResponse()->getStatusCode());
659
            $this->assertEquals(
660
                [
661
                    (object) [
662
                        'propertyPath' => 'app.$ref',
663
                        'message' => sprintf('Value "%s" is not a valid extref.', $url)
664
                    ],
665
                ],
666
                $client->getResults()
667
            );
668
        }
669
    }
670
671
    /**
672
     * test getting collection schema.
673
     * i avoid retesting everything (covered in /core/app), this test only
674
     * asserts translatable & extref representation
675
     *
676
     * @return void
677
     */
678
    public function testGetModuleCollectionSchemaInformationFormat()
679
    {
680
        $client = static::createRestClient();
681
682
        $client->request('GET', '/schema/core/module/collection');
683
        $results = $client->getResults();
684
685
        $this->assertEquals('object', $results->items->properties->app->type);
686
        $this->assertEquals('string', $results->items->properties->app->properties->{'$ref'}->type);
687
        $this->assertEquals('extref', $results->items->properties->app->properties->{'$ref'}->format);
688
689
        $service = $results->items->properties->service;
690
        $this->assertEquals('array', $service->type);
691
        $this->assertEquals('object', $service->items->properties->name->type);
692
        $this->assertEquals('string', $service->items->properties->name->properties->en->type);
693
        $this->assertEquals(['object', 'null'], $service->items->properties->description->type);
694
        $this->assertEquals('string', $service->items->properties->description->properties->en->type);
695
        $this->assertEquals('object', $service->items->properties->service->type);
696
        $this->assertEquals('string', $service->items->properties->service->properties->{'$ref'}->type);
697
    }
698
699
    /**
700
     * Encode RQL string
701
     *
702
     * @param string $value Value
703
     * @return string
704
     */
705 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...
706
    {
707
        return strtr(
708
            rawurlencode($value),
709
            [
710
                '-' => '%2D',
711
                '_' => '%5F',
712
                '.' => '%2E',
713
                '~' => '%7E',
714
            ]
715
        );
716
    }
717
}
718