Completed
Push — 7.5-to-master ( 442da5...4da3e7 )
by
unknown
25:31 queued 25:21
created

getIndexesToMatchData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 3
dl 0
loc 24
rs 9.536
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\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
        $data = [
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
        $setupFactory = $this->getSetupFactory();
1474
1475
        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...
1476
            $data = array_merge(
1477
                $data,
1478
                [
1479
                    [
1480
                        [
1481
                            'languages' => [
1482
                                'eng-GB',
1483
                                'ger-DE',
1484
                            ],
1485
                            'useAlwaysAvailable' => true,
1486
                            'excludeTranslationsFromAlwaysAvailable' => false,
1487
                        ],
1488
                        [
1489
                            [
1490
                                1,
1491
                                'eng-GB',
1492
                                [
1493
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core0',
1494
                                    self::SETUP_SHARED => 'localhost:8983/solr/core3',
1495
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1496
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core0_shard1_replica(_n)?1/',
1497
                                ],
1498
                                [
1499
                                    self::SETUP_DEDICATED => [
1500
                                        'searchHitIndex' => 0,
1501
                                        'preparedDataTestIndex' => 1,
1502
                                    ],
1503
                                    self::SETUP_SHARED => [
1504
                                        'searchHitIndex' => 0,
1505
                                        'preparedDataTestIndex' => 1,
1506
                                    ],
1507
                                    self::SETUP_SINGLE => [
1508
                                        'searchHitIndex' => 0,
1509
                                        'preparedDataTestIndex' => 1,
1510
                                    ],
1511
                                    self::SETUP_CLOUD => [
1512
                                        'searchHitIndex' => 0,
1513
                                        'preparedDataTestIndex' => 1,
1514
                                    ],
1515
                                ],
1516
                            ],
1517
                            [
1518
                                2,
1519
                                'ger-DE',
1520
                                [
1521
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1522
                                    self::SETUP_SHARED => 'localhost:8983/solr/core2',
1523
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1524
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1525
                                ],
1526
                                [
1527
                                    self::SETUP_DEDICATED => [
1528
                                        'searchHitIndex' => 2,
1529
                                        'preparedDataTestIndex' => 2,
1530
                                    ],
1531
                                    self::SETUP_SHARED => [
1532
                                        'searchHitIndex' => 2,
1533
                                        'preparedDataTestIndex' => 2,
1534
                                    ],
1535
                                    self::SETUP_SINGLE => [
1536
                                        'searchHitIndex' => 1,
1537
                                        'preparedDataTestIndex' => 2,
1538
                                    ],
1539
                                    self::SETUP_CLOUD => [
1540
                                        'searchHitIndex' => 1,
1541
                                        'preparedDataTestIndex' => 2,
1542
                                    ],
1543
                                ],
1544
                            ],
1545
                            [
1546
                                3,
1547
                                'por-PT',
1548
                                [
1549
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1550
                                    self::SETUP_SHARED => 'localhost:8983/solr/core0',
1551
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1552
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1553
                                ],
1554
                                [
1555
                                    self::SETUP_DEDICATED => [
1556
                                        'searchHitIndex' => 1,
1557
                                        'preparedDataTestIndex' => 2,
1558
                                    ],
1559
                                    self::SETUP_SHARED => [
1560
                                        'searchHitIndex' => 1,
1561
                                        'preparedDataTestIndex' => 2,
1562
                                    ],
1563
                                    self::SETUP_SINGLE => [
1564
                                        'searchHitIndex' => 2,
1565
                                        'preparedDataTestIndex' => 2,
1566
                                    ],
1567
                                    self::SETUP_CLOUD => [
1568
                                        'searchHitIndex' => 2,
1569
                                        'preparedDataTestIndex' => 2,
1570
                                    ],
1571
                                ],
1572
                            ],
1573
                        ],
1574
                    ],
1575
                    [
1576
                        [
1577
                            'languages' => [
1578
                                'ger-DE',
1579
                                'eng-GB',
1580
                            ],
1581
                            'useAlwaysAvailable' => true,
1582
                            'excludeTranslationsFromAlwaysAvailable' => false,
1583
                        ],
1584
                        [
1585
                            [
1586
                                1,
1587
                                'ger-DE',
1588
                                [
1589
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1590
                                    self::SETUP_SHARED => 'localhost:8983/solr/core2',
1591
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1592
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1593
                                ],
1594
                                [
1595
                                    self::SETUP_DEDICATED => [
1596
                                        'searchHitIndex' => 2,
1597
                                        'preparedDataTestIndex' => 2,
1598
                                    ],
1599
                                    self::SETUP_SHARED => [
1600
                                        'searchHitIndex' => 0,
1601
                                        'preparedDataTestIndex' => 1,
1602
                                    ],
1603
                                    self::SETUP_SINGLE => [
1604
                                        'searchHitIndex' => 0,
1605
                                        'preparedDataTestIndex' => 1,
1606
                                    ],
1607
                                    self::SETUP_CLOUD => [
1608
                                        'searchHitIndex' => 0,
1609
                                        'preparedDataTestIndex' => 1,
1610
                                    ],
1611
                                ],
1612
                            ],
1613
                            [
1614
                                2,
1615
                                'ger-DE',
1616
                                [
1617
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core3',
1618
                                    self::SETUP_SHARED => 'localhost:8983/solr/core2',
1619
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1620
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core1_shard1_replica(_n)?1/',
1621
                                ],
1622
                                [
1623
                                    self::SETUP_DEDICATED => [
1624
                                        'searchHitIndex' => 2,
1625
                                        'preparedDataTestIndex' => 2,
1626
                                    ],
1627
                                    self::SETUP_SHARED => [
1628
                                        'searchHitIndex' => 2,
1629
                                        'preparedDataTestIndex' => 2,
1630
                                    ],
1631
                                    self::SETUP_SINGLE => [
1632
                                        'searchHitIndex' => 1,
1633
                                        'preparedDataTestIndex' => 2,
1634
                                    ],
1635
                                    self::SETUP_CLOUD => [
1636
                                        'searchHitIndex' => 1,
1637
                                        'preparedDataTestIndex' => 2,
1638
                                    ],
1639
                                ],
1640
                            ],
1641
                            [
1642
                                3,
1643
                                'por-PT',
1644
                                [
1645
                                    self::SETUP_DEDICATED => 'localhost:8983/solr/core2',
1646
                                    self::SETUP_SHARED => 'localhost:8983/solr/core0',
1647
                                    self::SETUP_SINGLE => 'localhost:8983/solr/collection1',
1648
                                    self::SETUP_CLOUD => 'http://localhost:8983/solr/core3_shard1_replica(_n)?1/',
1649
                                ],
1650
                                [
1651
                                    self::SETUP_DEDICATED => [
1652
                                        'searchHitIndex' => 1,
1653
                                        'preparedDataTestIndex' => 2,
1654
                                    ],
1655
                                    self::SETUP_SHARED => [
1656
                                        'searchHitIndex' => 1,
1657
                                        'preparedDataTestIndex' => 2,
1658
                                    ],
1659
                                    self::SETUP_SINGLE => [
1660
                                        'searchHitIndex' => 2,
1661
                                        'preparedDataTestIndex' => 2,
1662
                                    ],
1663
                                    self::SETUP_CLOUD => [
1664
                                        'searchHitIndex' => 2,
1665
                                        'preparedDataTestIndex' => 2,
1666
                                    ],
1667
                                ],
1668
                            ],
1669
                        ],
1670
                    ],
1671
                ]
1672
            );
1673
        }
1674
1675
        return $data;
1676
    }
1677
1678
    protected function getSetupType()
1679
    {
1680
        if (getenv('SOLR_CLOUD')) {
1681
            return self::SETUP_CLOUD;
1682
        }
1683
1684
        $coresSetup = getenv('CORES_SETUP');
1685
        switch ($coresSetup) {
1686
            case self::SETUP_DEDICATED:
1687
                return self::SETUP_DEDICATED;
1688
            case self::SETUP_SHARED:
1689
                return self::SETUP_SHARED;
1690
            case self::SETUP_SINGLE:
1691
                return self::SETUP_SINGLE;
1692
        }
1693
1694
        throw new RuntimeException("Backend cores setup '{$coresSetup}' is not handled");
1695
    }
1696
1697
    protected function getIndexName($indexMap)
1698
    {
1699
        $setupFactory = $this->getSetupFactory();
1700
1701
        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...
1702
            $setupType = $this->getSetupType();
1703
1704
            return $indexMap[$setupType];
1705
        }
1706
1707
        return null;
1708
    }
1709
1710
    /**
1711
     * @dataProvider providerForTestFind
1712
     * @depends      testCreateTestContent
1713
     *
1714
     * @param array $languageSettings
1715
     * @param array $contentDataList
1716
     * @param array $context
1717
     */
1718
    public function testFindContent(
1719
        array $languageSettings,
1720
        array $contentDataList,
1721
        array $context
1722
    ) {
1723
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1724
        list($repository, $data) = $context;
1725
1726
        $queryProperties = [
1727
            'filter' => new Criterion\ContentTypeIdentifier('test-type'),
1728
            'sortClauses' => [
1729
                new SortClause\Field('test-type', 'sort_field'),
1730
            ],
1731
        ];
1732
1733
        $searchResult = $repository->getSearchService()->findContent(
1734
            new Query($queryProperties),
1735
            $languageSettings
1736
        );
1737
1738
        $this->assertEquals(count($contentDataList), $searchResult->totalCount);
1739
1740 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...
1741
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1742
            list($index, $contentNo) = $this->getIndexesToMatchData($contentData, $index, $contentNo);
1743
1744
            /** @var \eZ\Publish\Api\Repository\Values\Content\Content $content */
1745
            $content = $searchResult->searchHits[$index]->valueObject;
1746
1747
            $this->assertEquals(
1748
                $data[$contentNo]['content']->id,
1749
                $content->id
1750
            );
1751
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1752
            $this->assertEquals(
1753
                $translationLanguageCode,
1754
                $searchResult->searchHits[$index]->matchedTranslation
1755
            );
1756
        }
1757
    }
1758
1759
    /**
1760
     * @dataProvider providerForTestFind
1761
     * @depends      testCreateTestContent
1762
     *
1763
     * @param array $languageSettings
1764
     * @param array $contentDataList
1765
     * @param array $context
1766
     */
1767
    public function testFindLocationsSingle(
1768
        array $languageSettings,
1769
        array $contentDataList,
1770
        array $context
1771
    ) {
1772
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1773
        list($repository, $data) = $context;
1774
1775
        $queryProperties = [
1776
            'filter' => new Criterion\LogicalAnd(
1777
                [
1778
                    new Criterion\ContentTypeIdentifier('test-type'),
1779
                    new Criterion\Subtree('/1/2/'),
1780
                ]
1781
            ),
1782
            'sortClauses' => [
1783
                new SortClause\Field('test-type', 'sort_field'),
1784
            ],
1785
        ];
1786
1787
        $searchResult = $repository->getSearchService()->findLocations(
1788
            new LocationQuery($queryProperties),
1789
            $languageSettings
1790
        );
1791
1792
        $this->assertEquals(count($contentDataList), $searchResult->totalCount);
1793
1794 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...
1795
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1796
            list($index, $contentNo) = $this->getIndexesToMatchData($contentData, $index, $contentNo);
1797
1798
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1799
            $location = $searchResult->searchHits[$index]->valueObject;
1800
1801
            $this->assertEquals(
1802
                $data[$contentNo]['locations'][0]->id,
1803
                $location->id
1804
            );
1805
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1806
            $this->assertEquals(
1807
                $translationLanguageCode,
1808
                $searchResult->searchHits[$index]->matchedTranslation
1809
            );
1810
        }
1811
    }
1812
1813
    /**
1814
     * @dataProvider providerForTestFind
1815
     * @depends      testCreateTestContent
1816
     *
1817
     * @param array $languageSettings
1818
     * @param array $contentDataList
1819
     * @param array $context
1820
     */
1821
    public function testFindLocationsMultiple(
1822
        array $languageSettings,
1823
        array $contentDataList,
1824
        array $context
1825
    ) {
1826
        /** @var \eZ\Publish\Api\Repository\Repository $repository */
1827
        list($repository, $data) = $context;
1828
1829
        $queryProperties = [
1830
            'filter' => new Criterion\ContentTypeIdentifier('test-type'),
1831
            'sortClauses' => [
1832
                new SortClause\Location\Depth(Query::SORT_ASC),
1833
                new SortClause\Field('test-type', 'sort_field'),
1834
            ],
1835
        ];
1836
1837
        $searchResult = $repository->getSearchService()->findLocations(
1838
            new LocationQuery($queryProperties),
1839
            $languageSettings
1840
        );
1841
1842
        $this->assertEquals(count($contentDataList) * 2, $searchResult->totalCount);
1843
1844 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...
1845
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1846
            list($index, $contentNo) = $this->getIndexesToMatchData($contentData, $index, $contentNo);
1847
1848
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1849
            $location = $searchResult->searchHits[$index]->valueObject;
1850
1851
            $this->assertEquals(
1852
                $data[$contentNo]['locations'][0]->id,
1853
                $location->id
1854
            );
1855
            $this->assertIndexName($indexMap, $searchResult->searchHits[$index]);
1856
            $this->assertEquals(
1857
                $translationLanguageCode,
1858
                $searchResult->searchHits[$index]->matchedTranslation
1859
            );
1860
        }
1861
1862
        foreach ($contentDataList as $index => $contentData) {
1863
            list($contentNo, $translationLanguageCode, $indexMap) = $contentData;
1864
            list($index, $contentNo) = $this->getIndexesToMatchData($contentData, $index, $contentNo);
1865
1866
            $realIndex = $index + count($contentDataList);
1867
            /** @var \eZ\Publish\Api\Repository\Values\Content\Location $location */
1868
            $location = $searchResult->searchHits[$realIndex]->valueObject;
1869
1870
            $this->assertEquals(
1871
                $data[$contentNo]['locations'][1]->id,
1872
                $location->id
1873
            );
1874
            $this->assertIndexName($indexMap, $searchResult->searchHits[$realIndex]);
1875
            $this->assertEquals(
1876
                $translationLanguageCode,
1877
                $searchResult->searchHits[$realIndex]->matchedTranslation
1878
            );
1879
        }
1880
    }
1881
1882
    private function assertIndexName(array $indexMap, SearchHit $searchHit): void
1883
    {
1884
        $indexName = $this->getIndexName($indexMap);
1885
1886
        if ($indexName === null) {
1887
            $this->assertNull($searchHit->index);
1888
        } else {
1889
            $this->assertRegExp('~^' . $indexName . '$~', $searchHit->index);
1890
        }
1891
    }
1892
1893
    private function getIndexesToMatchData(
1894
        array $inputContentData,
1895
        int $currentSearchHitIndex,
1896
        int $currentPreparedDataTestIndex
1897
    ): array {
1898
        $indexesToMatchData = [
1899
            $currentSearchHitIndex,
1900
            $currentPreparedDataTestIndex,
1901
        ];
1902
1903
        if ($this->getSetupFactory() 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...
1904
            $setupType = $this->getSetupType();
1905
1906
            if ($customMatchResultIndexData = $inputContentData[3][$setupType] ?? null) {
1907
                // Use custom indexes
1908
                $indexesToMatchData = [
1909
                    $customMatchResultIndexData['searchHitIndex'],
1910
                    $customMatchResultIndexData['preparedDataTestIndex'],
1911
                ];
1912
            }
1913
        }
1914
1915
        return $indexesToMatchData;
1916
    }
1917
}
1918