Completed
Push — 7.5 ( 727c65...41b38d )
by
unknown
18:24
created

assertIndexName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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