Completed
Push — EZP-31047 ( 2e2645...f06309 )
by
unknown
38:15 queued 22:40
created

SearchServiceTranslationLanguageFallbackTest   B

Complexity

Total Complexity 23

Size/Duplication

Total Lines 1653
Duplicated Lines 2.72 %

Coupling/Cohesion

Components 2
Dependencies 23

Importance

Changes 0
Metric Value
wmc 23
lcom 2
cbo 23
dl 45
loc 1653
rs 8.8
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A createTestContentType() 0 36 1
A createContent() 0 36 3
B createTestContent() 0 60 1
A testCreateTestContent() 0 4 1
B providerForTestFind() 0 1280 1
A getSetupType() 0 18 5
A getIndexName() 0 12 2
A testFindContent() 15 38 2
A testFindLocationsSingle() 15 43 2
B testFindLocationsMultiple() 15 56 3
A assertIndexName() 0 10 2

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
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\API\Repository\Tests;
10
11
use eZ\Publish\API\Repository\Values\Content\Search\SearchHit;
12
use EzSystems\EzPlatformSolrSearchEngine\Tests\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory;
13
use eZ\Publish\API\Repository\Values\Content\LocationQuery;
14
use eZ\Publish\API\Repository\Values\Content\Query;
15
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
16
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
17
use DateTime;
18
use RuntimeException;
19
20
/**
21
 * Test case for field filtering operations in the SearchService.
22
 *
23
 * @see eZ\Publish\API\Repository\SearchService
24
 * @group integration
25
 * @group search
26
 * @group language_fallback
27
 */
28
class SearchServiceTranslationLanguageFallbackTest extends BaseTest
29
{
30
    const SETUP_DEDICATED = 'dedicated';
31
    const SETUP_SHARED = 'shared';
32
    const SETUP_SINGLE = 'single';
33
    const SETUP_CLOUD = 'cloud';
34
35
    /**
36
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
37
     */
38
    protected function createTestContentType()
39
    {
40
        $repository = $this->getRepository();
41
        $contentTypeService = $repository->getContentTypeService();
42
43
        $createStruct = $contentTypeService->newContentTypeCreateStruct('test-type');
44
        $createStruct->mainLanguageCode = 'eng-GB';
45
        $createStruct->names = ['eng-GB' => 'Test type'];
46
        $createStruct->creatorId = 14;
47
        $createStruct->creationDate = new DateTime();
48
49
        $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('search_field', 'ezinteger');
50
        $fieldCreate->names = ['eng-GB' => 'Search field'];
51
        $fieldCreate->fieldGroup = 'main';
52
        $fieldCreate->position = 1;
53
        $fieldCreate->isTranslatable = true;
54
        $fieldCreate->isSearchable = true;
55
56
        $createStruct->addFieldDefinition($fieldCreate);
57
58
        $fieldCreate = $contentTypeService->newFieldDefinitionCreateStruct('sort_field', 'ezinteger');
59
        $fieldCreate->names = ['eng-GB' => 'Sort field'];
60
        $fieldCreate->fieldGroup = 'main';
61
        $fieldCreate->position = 2;
62
        $fieldCreate->isTranslatable = false;
63
        $fieldCreate->isSearchable = true;
64
65
        $createStruct->addFieldDefinition($fieldCreate);
66
67
        $contentGroup = $contentTypeService->loadContentTypeGroupByIdentifier('Content');
68
        $contentTypeDraft = $contentTypeService->createContentType($createStruct, [$contentGroup]);
69
        $contentTypeService->publishContentTypeDraft($contentTypeDraft);
70
        $contentType = $contentTypeService->loadContentType($contentTypeDraft->id);
71
72
        return $contentType;
73
    }
74
75
    /**
76
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
77
     * @param array $searchValuesMap
78
     * @param string $mainLanguageCode
79
     * @param bool $alwaysAvailable
80
     * @param int $sortValue
81
     * @param array $parentLocationIds
82
     *
83
     * @return mixed
84
     */
85
    protected function createContent(
86
        $contentType,
87
        array $searchValuesMap,
88
        $mainLanguageCode,
89
        $alwaysAvailable,
90
        $sortValue,
91
        array $parentLocationIds
92
    ) {
93
        $repository = $this->getRepository();
94
        $contentService = $repository->getContentService();
95
        $locationService = $repository->getLocationService();
96
97
        $contentCreateStruct = $contentService->newContentCreateStruct($contentType, $mainLanguageCode);
98
        $contentCreateStruct->alwaysAvailable = $alwaysAvailable;
99
100
        foreach ($searchValuesMap as $languageCode => $searchValue) {
101
            $contentCreateStruct->setField('search_field', $searchValue, $languageCode);
102
        }
103
104
        $contentCreateStruct->setField('sort_field', $sortValue, $mainLanguageCode);
105
106
        $data = [];
107
        $data['content'] = $contentService->publishVersion(
108
            $contentService->createContent($contentCreateStruct)->versionInfo
109
        );
110
111
        foreach ($parentLocationIds as $parentLocationId) {
112
            $locationCreateStruct = $locationService->newLocationCreateStruct($parentLocationId);
113
            $data['locations'][] = $locationService->createLocation(
114
                $data['content']->contentInfo,
115
                $locationCreateStruct
116
            );
117
        }
118
119
        return $data;
120
    }
121
122
    /**
123
     * @param array $parentLocationIds
124
     *
125
     * @return array
126
     */
127
    public function createTestContent(array $parentLocationIds)
128
    {
129
        $repository = $this->getRepository();
130
        $languageService = $repository->getContentLanguageService();
131
132
        $langCreateStruct = $languageService->newLanguageCreateStruct();
133
        $langCreateStruct->languageCode = 'por-PT';
134
        $langCreateStruct->name = 'Portuguese (portuguese)';
135
        $langCreateStruct->enabled = true;
136
137
        $languageService->createLanguage($langCreateStruct);
138
139
        $contentType = $this->createTestContentType();
140
141
        $context = [
142
            $repository,
143
            [
144
                1 => $this->createContent(
145
                    $contentType,
146
                    [
147
                        'eng-GB' => 1,
148
                        'ger-DE' => 2,
149
                        'por-PT' => 3,
150
                    ],
151
                    'eng-GB',
152
                    false,
153
                    1,
154
                    $parentLocationIds
155
                ),
156
                2 => $this->createContent(
157
                    $contentType,
158
                    [
159
                        //"eng-GB" => ,
160
                        'ger-DE' => 1,
161
                        'por-PT' => 2,
162
                    ],
163
                    'por-PT',
164
                    true,
165
                    2,
166
                    $parentLocationIds
167
                ),
168
                3 => $this->createContent(
169
                    $contentType,
170
                    [
171
                        //"eng-GB" => ,
172
                        //"ger-DE" => ,
173
                        'por-PT' => 1,
174
                    ],
175
                    'por-PT',
176
                    false,
177
                    3,
178
                    $parentLocationIds
179
                ),
180
            ],
181
        ];
182
183
        $this->refreshSearch($repository);
184
185
        return $context;
186
    }
187
188
    public function testCreateTestContent()
189
    {
190
        return $this->createTestContent([2, 12]);
191
    }
192
193
    public function providerForTestFind()
194
    {
195
        return [
196
            0 => [
197
                [
198
                    'languages' => [
199
                        'eng-GB',
200
                        'ger-DE',
201
                        'por-PT',
202
                    ],
203
                    'useAlwaysAvailable' => false,
204
                ],
205
                [
206
                    [
207
                        1,
208
                        'eng-GB',
209
                        [
210
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
211
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
212
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
213
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
214
                        ],
215
                    ],
216
                    [
217
                        2,
218
                        'ger-DE',
219
                        [
220
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
221
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
222
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
223
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
224
                        ],
225
                    ],
226
                    [
227
                        3,
228
                        'por-PT',
229
                        [
230
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
231
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
232
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
233
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
234
                        ],
235
                    ],
236
                ],
237
            ],
238
            1 => [
239
                [
240
                    'languages' => [
241
                        'eng-GB',
242
                        'por-PT',
243
                        'ger-DE',
244
                    ],
245
                    'useAlwaysAvailable' => false,
246
                ],
247
                [
248
                    [
249
                        1,
250
                        'eng-GB',
251
                        [
252
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
253
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
254
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
255
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
256
                        ],
257
                    ],
258
                    [
259
                        2,
260
                        'por-PT',
261
                        [
262
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
263
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
264
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
265
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
266
                        ],
267
                    ],
268
                    [
269
                        3,
270
                        'por-PT',
271
                        [
272
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
273
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
274
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
275
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
276
                        ],
277
                    ],
278
                ],
279
            ],
280
            2 => [
281
                [
282
                    'languages' => [
283
                        'ger-DE',
284
                        'eng-GB',
285
                        'por-PT',
286
                    ],
287
                    'useAlwaysAvailable' => false,
288
                ],
289
                [
290
                    [
291
                        1,
292
                        'ger-DE',
293
                        [
294
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
295
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
296
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
297
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
298
                        ],
299
                    ],
300
                    [
301
                        2,
302
                        'ger-DE',
303
                        [
304
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
305
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
306
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
307
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
308
                        ],
309
                    ],
310
                    [
311
                        3,
312
                        'por-PT',
313
                        [
314
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
315
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
316
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
317
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
318
                        ],
319
                    ],
320
                ],
321
            ],
322
            3 => [
323
                [
324
                    'languages' => [
325
                        'ger-DE',
326
                        'por-PT',
327
                        'eng-GB',
328
                    ],
329
                    'useAlwaysAvailable' => false,
330
                ],
331
                [
332
                    [
333
                        1,
334
                        'ger-DE',
335
                        [
336
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
337
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
338
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
339
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
340
                        ],
341
                    ],
342
                    [
343
                        2,
344
                        'ger-DE',
345
                        [
346
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
347
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
348
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
349
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
350
                        ],
351
                    ],
352
                    [
353
                        3,
354
                        'por-PT',
355
                        [
356
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
357
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
358
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
359
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
360
                        ],
361
                    ],
362
                ],
363
            ],
364
            4 => [
365
                [
366
                    'languages' => [
367
                        'por-PT',
368
                        'eng-GB',
369
                        'ger-DE',
370
                    ],
371
                    'useAlwaysAvailable' => false,
372
                ],
373
                [
374
                    [
375
                        1,
376
                        'por-PT',
377
                        [
378
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
379
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
380
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
381
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
382
                        ],
383
                    ],
384
                    [
385
                        2,
386
                        'por-PT',
387
                        [
388
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
389
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
390
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
391
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
392
                        ],
393
                    ],
394
                    [
395
                        3,
396
                        'por-PT',
397
                        [
398
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
399
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
400
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
401
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
402
                        ],
403
                    ],
404
                ],
405
            ],
406
            5 => [
407
                [
408
                    'languages' => [
409
                        'por-PT',
410
                        'eng-GB',
411
                        'ger-DE',
412
                    ],
413
                    'useAlwaysAvailable' => false,
414
                ],
415
                [
416
                    [
417
                        1,
418
                        'por-PT',
419
                        [
420
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
421
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
422
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
423
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
424
                        ],
425
                    ],
426
                    [
427
                        2,
428
                        'por-PT',
429
                        [
430
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
431
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
432
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
433
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
434
                        ],
435
                    ],
436
                    [
437
                        3,
438
                        'por-PT',
439
                        [
440
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
441
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
442
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
443
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
444
                        ],
445
                    ],
446
                ],
447
            ],
448
            6 => [
449
                [
450
                    'languages' => [
451
                        'eng-GB',
452
                        'ger-DE',
453
                    ],
454
                    'useAlwaysAvailable' => false,
455
                ],
456
                [
457
                    [
458
                        1,
459
                        'eng-GB',
460
                        [
461
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
462
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
463
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
464
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
465
                        ],
466
                    ],
467
                    [
468
                        2,
469
                        'ger-DE',
470
                        [
471
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
472
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
473
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
474
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
475
                        ],
476
                    ],
477
                ],
478
            ],
479
            7 => [
480
                [
481
                    'languages' => [
482
                        'ger-DE',
483
                        'eng-GB',
484
                    ],
485
                    'useAlwaysAvailable' => false,
486
                ],
487
                [
488
                    [
489
                        1,
490
                        'ger-DE',
491
                        [
492
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
493
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
494
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
495
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
496
                        ],
497
                    ],
498
                    [
499
                        2,
500
                        'ger-DE',
501
                        [
502
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
503
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
504
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
505
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
506
                        ],
507
                    ],
508
                ],
509
            ],
510
            8 => [
511
                [
512
                    'languages' => [
513
                        'eng-GB',
514
                        'por-PT',
515
                    ],
516
                    'useAlwaysAvailable' => false,
517
                ],
518
                [
519
                    [
520
                        1,
521
                        'eng-GB',
522
                        [
523
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
524
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
525
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
526
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
527
                        ],
528
                    ],
529
                    [
530
                        2,
531
                        'por-PT',
532
                        [
533
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
534
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
535
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
536
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
537
                        ],
538
                    ],
539
                    [
540
                        3,
541
                        'por-PT',
542
                        [
543
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
544
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
545
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
546
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
547
                        ],
548
                    ],
549
                ],
550
            ],
551
            9 => [
552
                [
553
                    'languages' => [
554
                        'por-PT',
555
                        'eng-GB',
556
                    ],
557
                    'useAlwaysAvailable' => false,
558
                ],
559
                [
560
                    [
561
                        1,
562
                        'por-PT',
563
                        [
564
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
565
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
566
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
567
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
568
                        ],
569
                    ],
570
                    [
571
                        2,
572
                        'por-PT',
573
                        [
574
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
575
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
576
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
577
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
578
                        ],
579
                    ],
580
                    [
581
                        3,
582
                        'por-PT',
583
                        [
584
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
585
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
586
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
587
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
588
                        ],
589
                    ],
590
                ],
591
            ],
592
            10 => [
593
                [
594
                    'languages' => [
595
                        'ger-DE',
596
                        'por-PT',
597
                    ],
598
                    'useAlwaysAvailable' => false,
599
                ],
600
                [
601
                    [
602
                        1,
603
                        'ger-DE',
604
                        [
605
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
606
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
607
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
608
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
609
                        ],
610
                    ],
611
                    [
612
                        2,
613
                        'ger-DE',
614
                        [
615
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
616
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
617
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
618
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
619
                        ],
620
                    ],
621
                    [
622
                        3,
623
                        'por-PT',
624
                        [
625
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
626
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
627
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
628
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
629
                        ],
630
                    ],
631
                ],
632
            ],
633
            11 => [
634
                [
635
                    'languages' => [
636
                        'por-PT',
637
                        'eng-GB',
638
                    ],
639
                    'useAlwaysAvailable' => false,
640
                ],
641
                [
642
                    [
643
                        1,
644
                        'por-PT',
645
                        [
646
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
647
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
648
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
649
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
650
                        ],
651
                    ],
652
                    [
653
                        2,
654
                        'por-PT',
655
                        [
656
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
657
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
658
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
659
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
660
                        ],
661
                    ],
662
                    [
663
                        3,
664
                        'por-PT',
665
                        [
666
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
667
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
668
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
669
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
670
                        ],
671
                    ],
672
                ],
673
            ],
674
            12 => [
675
                [
676
                    'languages' => [
677
                        'eng-GB',
678
                    ],
679
                    'useAlwaysAvailable' => false,
680
                ],
681
                [
682
                    [
683
                        1,
684
                        'eng-GB',
685
                        [
686
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
687
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
688
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
689
                            self::SETUP_CLOUD => 'localhost:8983/solr/core0',
690
                        ],
691
                    ],
692
                ],
693
            ],
694
            13 => [
695
                [
696
                    'languages' => [
697
                        'ger-DE',
698
                    ],
699
                    'useAlwaysAvailable' => false,
700
                ],
701
                [
702
                    [
703
                        1,
704
                        'ger-DE',
705
                        [
706
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
707
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
708
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
709
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
710
                        ],
711
                    ],
712
                    [
713
                        2,
714
                        'ger-DE',
715
                        [
716
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
717
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
718
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
719
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
720
                        ],
721
                    ],
722
                ],
723
            ],
724
            14 => [
725
                [
726
                    'languages' => [
727
                        'por-PT',
728
                    ],
729
                    'useAlwaysAvailable' => false,
730
                ],
731
                [
732
                    [
733
                        1,
734
                        'por-PT',
735
                        [
736
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
737
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
738
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
739
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
740
                        ],
741
                    ],
742
                    [
743
                        2,
744
                        'por-PT',
745
                        [
746
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
747
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
748
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
749
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
750
                        ],
751
                    ],
752
                    [
753
                        3,
754
                        'por-PT',
755
                        [
756
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
757
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
758
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
759
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
760
                        ],
761
                    ],
762
                ],
763
            ],
764
            15 => [
765
                [
766
                    'languages' => [
767
                        'eng-US',
768
                    ],
769
                    'useAlwaysAvailable' => false,
770
                ],
771
                [],
772
            ],
773
            16 => [
774
                [
775
                    'languages' => [
776
                        'eng-GB',
777
                        'ger-DE',
778
                        'por-PT',
779
                    ],
780
                    'useAlwaysAvailable' => true,
781
                ],
782
                [
783
                    [
784
                        1,
785
                        'eng-GB',
786
                        [
787
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
788
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
789
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
790
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
791
                        ],
792
                    ],
793
                    [
794
                        2,
795
                        'ger-DE',
796
                        [
797
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
798
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
799
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
800
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
801
                        ],
802
                    ],
803
                    [
804
                        3,
805
                        'por-PT',
806
                        [
807
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
808
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
809
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
810
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
811
                        ],
812
                    ],
813
                ],
814
            ],
815
            17 => [
816
                [
817
                    'languages' => [
818
                        'eng-GB',
819
                        'por-PT',
820
                        'ger-DE',
821
                    ],
822
                    'useAlwaysAvailable' => true,
823
                ],
824
                [
825
                    [
826
                        1,
827
                        'eng-GB',
828
                        [
829
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
830
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
831
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
832
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
833
                        ],
834
                    ],
835
                    [
836
                        2,
837
                        'por-PT',
838
                        [
839
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
840
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
841
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
842
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
843
                        ],
844
                    ],
845
                    [
846
                        3,
847
                        'por-PT',
848
                        [
849
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
850
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
851
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
852
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
853
                        ],
854
                    ],
855
                ],
856
            ],
857
            18 => [
858
                [
859
                    'languages' => [
860
                        'ger-DE',
861
                        'eng-GB',
862
                        'por-PT',
863
                    ],
864
                    'useAlwaysAvailable' => true,
865
                ],
866
                [
867
                    [
868
                        1,
869
                        'ger-DE',
870
                        [
871
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
872
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
873
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
874
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
875
                        ],
876
                    ],
877
                    [
878
                        2,
879
                        'ger-DE',
880
                        [
881
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
882
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
883
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
884
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
885
                        ],
886
                    ],
887
                    [
888
                        3,
889
                        'por-PT',
890
                        [
891
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
892
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
893
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
894
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
895
                        ],
896
                    ],
897
                ],
898
            ],
899
            19 => [
900
                [
901
                    'languages' => [
902
                        'ger-DE',
903
                        'por-PT',
904
                        'eng-GB',
905
                    ],
906
                    'useAlwaysAvailable' => true,
907
                ],
908
                [
909
                    [
910
                        1,
911
                        'ger-DE',
912
                        [
913
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
914
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
915
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
916
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
917
                        ],
918
                    ],
919
                    [
920
                        2,
921
                        'ger-DE',
922
                        [
923
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
924
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
925
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
926
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
927
                        ],
928
                    ],
929
                    [
930
                        3,
931
                        'por-PT',
932
                        [
933
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
934
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
935
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
936
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
937
                        ],
938
                    ],
939
                ],
940
            ],
941
            20 => [
942
                [
943
                    'languages' => [
944
                        'por-PT',
945
                        'eng-GB',
946
                        'ger-DE',
947
                    ],
948
                    'useAlwaysAvailable' => true,
949
                ],
950
                [
951
                    [
952
                        1,
953
                        'por-PT',
954
                        [
955
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
956
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
957
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
958
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
959
                        ],
960
                    ],
961
                    [
962
                        2,
963
                        'por-PT',
964
                        [
965
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
966
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
967
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
968
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
969
                        ],
970
                    ],
971
                    [
972
                        3,
973
                        'por-PT',
974
                        [
975
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
976
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
977
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
978
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
979
                        ],
980
                    ],
981
                ],
982
            ],
983
            21 => [
984
                [
985
                    'languages' => [
986
                        'por-PT',
987
                        'eng-GB',
988
                        'ger-DE',
989
                    ],
990
                    'useAlwaysAvailable' => true,
991
                ],
992
                [
993
                    [
994
                        1,
995
                        'por-PT',
996
                        [
997
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
998
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
999
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1000
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1001
                        ],
1002
                    ],
1003
                    [
1004
                        2,
1005
                        'por-PT',
1006
                        [
1007
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1008
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1009
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1010
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1011
                        ],
1012
                    ],
1013
                    [
1014
                        3,
1015
                        'por-PT',
1016
                        [
1017
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1018
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1019
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1020
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1021
                        ],
1022
                    ],
1023
                ],
1024
            ],
1025
            22 => [
1026
                [
1027
                    'languages' => [
1028
                        'eng-GB',
1029
                        'ger-DE',
1030
                    ],
1031
                    'useAlwaysAvailable' => true,
1032
                ],
1033
                [
1034
                    [
1035
                        1,
1036
                        'eng-GB',
1037
                        [
1038
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
1039
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
1040
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1041
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
1042
                        ],
1043
                    ],
1044
                    [
1045
                        2,
1046
                        'ger-DE',
1047
                        [
1048
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1049
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1050
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1051
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1052
                        ],
1053
                    ],
1054
                ],
1055
            ],
1056
            23 => [
1057
                [
1058
                    'languages' => [
1059
                        'ger-DE',
1060
                        'eng-GB',
1061
                    ],
1062
                    'useAlwaysAvailable' => true,
1063
                ],
1064
                [
1065
                    [
1066
                        1,
1067
                        'ger-DE',
1068
                        [
1069
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1070
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1071
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1072
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1073
                        ],
1074
                    ],
1075
                    [
1076
                        2,
1077
                        'ger-DE',
1078
                        [
1079
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1080
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1081
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1082
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1083
                        ],
1084
                    ],
1085
                ],
1086
            ],
1087
            24 => [
1088
                [
1089
                    'languages' => [
1090
                        'eng-GB',
1091
                        'por-PT',
1092
                    ],
1093
                    'useAlwaysAvailable' => true,
1094
                ],
1095
                [
1096
                    [
1097
                        1,
1098
                        'eng-GB',
1099
                        [
1100
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
1101
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
1102
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1103
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
1104
                        ],
1105
                    ],
1106
                    [
1107
                        2,
1108
                        'por-PT',
1109
                        [
1110
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1111
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1112
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1113
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1114
                        ],
1115
                    ],
1116
                    [
1117
                        3,
1118
                        'por-PT',
1119
                        [
1120
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1121
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1122
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1123
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1124
                        ],
1125
                    ],
1126
                ],
1127
            ],
1128
            25 => [
1129
                [
1130
                    'languages' => [
1131
                        'por-PT',
1132
                        'eng-GB',
1133
                    ],
1134
                    'useAlwaysAvailable' => true,
1135
                ],
1136
                [
1137
                    [
1138
                        1,
1139
                        'por-PT',
1140
                        [
1141
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1142
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1143
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1144
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1145
                        ],
1146
                    ],
1147
                    [
1148
                        2,
1149
                        'por-PT',
1150
                        [
1151
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1152
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1153
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1154
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1155
                        ],
1156
                    ],
1157
                    [
1158
                        3,
1159
                        'por-PT',
1160
                        [
1161
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1162
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1163
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1164
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1165
                        ],
1166
                    ],
1167
                ],
1168
            ],
1169
            26 => [
1170
                [
1171
                    'languages' => [
1172
                        'ger-DE',
1173
                        'por-PT',
1174
                    ],
1175
                    'useAlwaysAvailable' => true,
1176
                ],
1177
                [
1178
                    [
1179
                        1,
1180
                        'ger-DE',
1181
                        [
1182
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1183
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1184
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1185
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1186
                        ],
1187
                    ],
1188
                    [
1189
                        2,
1190
                        'ger-DE',
1191
                        [
1192
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1193
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1194
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1195
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1196
                        ],
1197
                    ],
1198
                    [
1199
                        3,
1200
                        'por-PT',
1201
                        [
1202
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1203
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1204
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1205
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1206
                        ],
1207
                    ],
1208
                ],
1209
            ],
1210
            27 => [
1211
                [
1212
                    'languages' => [
1213
                        'por-PT',
1214
                        'eng-GB',
1215
                    ],
1216
                    'useAlwaysAvailable' => true,
1217
                ],
1218
                [
1219
                    [
1220
                        1,
1221
                        'por-PT',
1222
                        [
1223
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1224
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1225
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1226
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1227
                        ],
1228
                    ],
1229
                    [
1230
                        2,
1231
                        'por-PT',
1232
                        [
1233
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1234
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1235
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1236
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1237
                        ],
1238
                    ],
1239
                    [
1240
                        3,
1241
                        'por-PT',
1242
                        [
1243
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1244
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1245
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1246
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1247
                        ],
1248
                    ],
1249
                ],
1250
            ],
1251
            28 => [
1252
                [
1253
                    'languages' => [
1254
                        'eng-GB',
1255
                    ],
1256
                    'useAlwaysAvailable' => true,
1257
                ],
1258
                [
1259
                    [
1260
                        1,
1261
                        'eng-GB',
1262
                        [
1263
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
1264
                            self::SETUP_SHARED => 'localhost:8983/solr/core3',
1265
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1266
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
1267
                        ],
1268
                    ],
1269
                    [
1270
                        2,
1271
                        'por-PT',
1272
                        [
1273
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1274
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1275
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1276
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1277
                        ],
1278
                    ],
1279
                ],
1280
            ],
1281
            29 => [
1282
                [
1283
                    'languages' => [
1284
                        'ger-DE',
1285
                    ],
1286
                    'useAlwaysAvailable' => true,
1287
                ],
1288
                [
1289
                    [
1290
                        1,
1291
                        'ger-DE',
1292
                        [
1293
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1294
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1295
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1296
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1297
                        ],
1298
                    ],
1299
                    [
1300
                        2,
1301
                        'ger-DE',
1302
                        [
1303
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1304
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1305
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1306
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1307
                        ],
1308
                    ],
1309
                ],
1310
            ],
1311
            30 => [
1312
                [
1313
                    'languages' => [
1314
                        'por-PT',
1315
                    ],
1316
                    'useAlwaysAvailable' => true,
1317
                ],
1318
                [
1319
                    [
1320
                        1,
1321
                        'por-PT',
1322
                        [
1323
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1324
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1325
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1326
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1327
                        ],
1328
                    ],
1329
                    [
1330
                        2,
1331
                        'por-PT',
1332
                        [
1333
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1334
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1335
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1336
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1337
                        ],
1338
                    ],
1339
                    [
1340
                        3,
1341
                        'por-PT',
1342
                        [
1343
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1344
                            self::SETUP_SHARED => 'localhost:8983/solr/core2',
1345
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1346
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core2_shard1_replica(_n)?1/',
1347
                        ],
1348
                    ],
1349
                ],
1350
            ],
1351
            31 => [
1352
                [
1353
                    'languages' => [
1354
                        'eng-US',
1355
                    ],
1356
                    'useAlwaysAvailable' => true,
1357
                ],
1358
                [
1359
                    [
1360
                        2,
1361
                        'por-PT',
1362
                        [
1363
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1364
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1365
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1366
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1367
                        ],
1368
                    ],
1369
                ],
1370
            ],
1371
            32 => [
1372
                [
1373
                    'languages' => [],
1374
                    'useAlwaysAvailable' => true,
1375
                ],
1376
                $mainLanguages = [
1377
                    [
1378
                        1,
1379
                        'eng-GB',
1380
                        [
1381
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
1382
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1383
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1384
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1385
                        ],
1386
                    ],
1387
                    [
1388
                        2,
1389
                        'por-PT',
1390
                        [
1391
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1392
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1393
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1394
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1395
                        ],
1396
                    ],
1397
                    [
1398
                        3,
1399
                        'por-PT',
1400
                        [
1401
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1402
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1403
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1404
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1405
                        ],
1406
                    ],
1407
                ],
1408
            ],
1409
            33 => [
1410
                [
1411
                    'languages' => [],
1412
                    'useAlwaysAvailable' => false,
1413
                ],
1414
                $mainLanguages,
1415
            ],
1416
            34 => [
1417
                [
1418
                    'languages' => [],
1419
                    'useAlwaysAvailable' => true,
1420
                ],
1421
                $mainLanguages,
1422
            ],
1423
            35 => [
1424
                [
1425
                    'languages' => [],
1426
                    'useAlwaysAvailable' => false,
1427
                ],
1428
                $mainLanguages,
1429
            ],
1430
            36 => [
1431
                [
1432
                    'languages' => [],
1433
                ],
1434
                $mainLanguages,
1435
            ],
1436
            37 => [
1437
                [
1438
                    'languages' => [],
1439
                ],
1440
                $mainLanguages,
1441
            ],
1442
            38 => [
1443
                [
1444
                    'languages' => [
1445
                        'eng-US',
1446
                    ],
1447
                    'useAlwaysAvailable' => false,
1448
                ],
1449
                [],
1450
            ],
1451
            39 => [
1452
                [
1453
                    'languages' => [
1454
                        'eng-US',
1455
                    ],
1456
                    'useAlwaysAvailable' => true,
1457
                ],
1458
                [
1459
                    [
1460
                        2,
1461
                        'por-PT',
1462
                        [
1463
                            self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1464
                            self::SETUP_SHARED => 'localhost:8983/solr/core0',
1465
                            self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1466
                            self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1467
                        ],
1468
                    ],
1469
                ],
1470
            ],
1471
        ];
1472
    }
1473
1474
    protected function getSetupType()
1475
    {
1476
        if (getenv('SOLR_CLOUD')) {
1477
            return self::SETUP_CLOUD;
1478
        }
1479
1480
        $coresSetup = getenv('CORES_SETUP');
1481
        switch ($coresSetup) {
1482
            case self::SETUP_DEDICATED:
1483
                return self::SETUP_DEDICATED;
1484
            case self::SETUP_SHARED:
1485
                return self::SETUP_SHARED;
1486
            case self::SETUP_SINGLE:
1487
                return self::SETUP_SINGLE;
1488
        }
1489
1490
        throw new RuntimeException("Backend cores setup '{$coresSetup}' is not handled");
1491
    }
1492
1493
    protected function getIndexName($indexMap)
1494
    {
1495
        $setupFactory = $this->getSetupFactory();
1496
1497
        if ($setupFactory instanceof LegacySolrSetupFactory) {
0 ignored issues
show
Bug introduced by
The class EzSystems\EzPlatformSolr...tory\LegacySetupFactory does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
1498
            $setupType = $this->getSetupType();
1499
1500
            return $indexMap[$setupType];
1501
        }
1502
1503
        return null;
1504
    }
1505
1506
    /**
1507
     * @dataProvider providerForTestFind
1508
     * @depends      testCreateTestContent
1509
     *
1510
     * @param array $languageSettings
1511
     * @param array $contentDataList
1512
     * @param array $context
1513
     */
1514
    public function testFindContent(
1515
        array $languageSettings,
1516
        array $contentDataList,
1517
        array $context
1518
    ) {
1519
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1520
        list($repository, $data) = $context;
1521
1522
        $queryProperties = [
1523
            'filter' => new Criterion\ContentTypeIdentifier('test-type'),
1524
            'sortClauses' => [
1525
                new SortClause\Field('test-type', 'sort_field'),
1526
            ],
1527
        ];
1528
1529
        $searchResult = $repository->getSearchService()->findContent(
1530
            new Query($queryProperties),
1531
            $languageSettings
1532
        );
1533
1534
        $this->assertEquals(count($contentDataList), $searchResult->totalCount);
1535
1536 View Code Duplication
        foreach ($contentDataList as $index => $contentData) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1537
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1538
            /** @var \eZ\Publish\Api\Repository\Values\Content\Content $content */
1539
            $content = $searchResult->searchHits[$index]->valueObject;
1540
1541
            $this->assertEquals(
1542
                $data[$contentNo]['content']->id,
1543
                $content->id
1544
            );
1545
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1546
            $this->assertEquals(
1547
                $translationLanguageCode,
1548
                $searchResult->searchHits[$index]->matchedTranslation
1549
            );
1550
        }
1551
    }
1552
1553
    /**
1554
     * @dataProvider providerForTestFind
1555
     * @depends      testCreateTestContent
1556
     *
1557
     * @param array $languageSettings
1558
     * @param array $contentDataList
1559
     * @param array $context
1560
     */
1561
    public function testFindLocationsSingle(
1562
        array $languageSettings,
1563
        array $contentDataList,
1564
        array $context
1565
    ) {
1566
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1567
        list($repository, $data) = $context;
1568
1569
        $queryProperties = [
1570
            'filter' => new Criterion\LogicalAnd(
1571
                [
1572
                    new Criterion\ContentTypeIdentifier('test-type'),
1573
                    new Criterion\Subtree('/1/2/'),
1574
                ]
1575
            ),
1576
            'sortClauses' => [
1577
                new SortClause\Field('test-type', 'sort_field'),
1578
            ],
1579
        ];
1580
1581
        $searchResult = $repository->getSearchService()->findLocations(
1582
            new LocationQuery($queryProperties),
1583
            $languageSettings
1584
        );
1585
1586
        $this->assertEquals(count($contentDataList), $searchResult->totalCount);
1587
1588 View Code Duplication
        foreach ($contentDataList as $index => $contentData) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1589
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1590
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1591
            $location = $searchResult->searchHits[$index]->valueObject;
1592
1593
            $this->assertEquals(
1594
                $data[$contentNo]['locations'][0]->id,
1595
                $location->id
1596
            );
1597
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1598
            $this->assertEquals(
1599
                $translationLanguageCode,
1600
                $searchResult->searchHits[$index]->matchedTranslation
1601
            );
1602
        }
1603
    }
1604
1605
    /**
1606
     * @dataProvider providerForTestFind
1607
     * @depends      testCreateTestContent
1608
     *
1609
     * @param array $languageSettings
1610
     * @param array $contentDataList
1611
     * @param array $context
1612
     */
1613
    public function testFindLocationsMultiple(
1614
        array $languageSettings,
1615
        array $contentDataList,
1616
        array $context
1617
    ) {
1618
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1619
        list($repository, $data) = $context;
1620
1621
        $queryProperties = [
1622
            'filter' => new Criterion\ContentTypeIdentifier('test-type'),
1623
            'sortClauses' => [
1624
                new SortClause\Location\Depth(Query::SORT_ASC),
1625
                new SortClause\Field('test-type', 'sort_field'),
1626
            ],
1627
        ];
1628
1629
        $searchResult = $repository->getSearchService()->findLocations(
1630
            new LocationQuery($queryProperties),
1631
            $languageSettings
1632
        );
1633
1634
        $this->assertEquals(count($contentDataList) * 2, $searchResult->totalCount);
1635
1636 View Code Duplication
        foreach ($contentDataList as $index => $contentData) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
1637
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1638
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1639
            $location = $searchResult->searchHits[$index]->valueObject;
1640
1641
            $this->assertEquals(
1642
                $data[$contentNo]['locations'][0]->id,
1643
                $location->id
1644
            );
1645
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1646
            $this->assertEquals(
1647
                $translationLanguageCode,
1648
                $searchResult->searchHits[$index]->matchedTranslation
1649
            );
1650
        }
1651
1652
        foreach ($contentDataList as $index => $contentData) {
1653
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1654
            $realIndex = $index + count($contentDataList);
1655
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1656
            $location = $searchResult->searchHits[$realIndex]->valueObject;
1657
1658
            $this->assertEquals(
1659
                $data[$contentNo]['locations'][1]->id,
1660
                $location->id
1661
            );
1662
            $this->assertIndexName($indexMap, $searchResult->searchHits[$realIndex]);
1663
            $this->assertEquals(
1664
                $translationLanguageCode,
1665
                $searchResult->searchHits[$realIndex]->matchedTranslation
1666
            );
1667
        }
1668
    }
1669
1670
    private function assertIndexName(array $indexMap, SearchHit $searchHit): void
1671
    {
1672
        $indexName = $this->getIndexName($indexMap);
1673
1674
        if ($indexName === null) {
1675
            $this->assertNull($searchHit->index);
1676
        } else {
1677
            $this->assertRegExp('~^' . $indexName . '$~', $searchHit->index);
1678
        }
1679
    }
1680
}
1681