6
6
7
7
use Meilisearch \Bundle \Tests \BaseKernelTestCase ;
8
8
use Meilisearch \Bundle \Tests \Entity \DummyCustomGroups ;
9
+ use Meilisearch \Bundle \Tests \Entity \DynamicSettings ;
9
10
use Meilisearch \Bundle \Tests \Entity \SelfNormalizable ;
10
11
use Meilisearch \Client ;
11
12
use Meilisearch \Endpoints \Indexes ;
@@ -77,9 +78,9 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
77
78
Importing for index Meilisearch\Bundle\Tests\Entity\Post
78
79
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index (6 indexed since start)
79
80
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index (6 indexed since start)
80
- Settings updated.
81
- Settings updated.
82
- Settings updated.
81
+ Settings updated of "sf_phpunit__posts" .
82
+ Settings updated of "sf_phpunit__posts" .
83
+ Settings updated of "sf_phpunit__posts" .
83
84
Importing for index Meilisearch\Bundle\Tests\Entity\Comment
84
85
Importing for index Meilisearch\Bundle\Tests\Entity\Tag
85
86
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index (6 indexed since start)
@@ -89,6 +90,11 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
89
90
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Page entities into sf_phpunit__pages index (6 indexed since start)
90
91
Importing for index Meilisearch\Bundle\Tests\Entity\SelfNormalizable
91
92
Importing for index Meilisearch\Bundle\Tests\Entity\DummyCustomGroups
93
+ Importing for index Meilisearch\Bundle\Tests\Entity\DynamicSettings
94
+ Settings updated of "sf_phpunit__dynamic_settings".
95
+ Settings updated of "sf_phpunit__dynamic_settings".
96
+ Settings updated of "sf_phpunit__dynamic_settings".
97
+ Settings updated of "sf_phpunit__dynamic_settings".
92
98
Importing for index Meilisearch\Bundle\Tests\Entity\Post
93
99
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__posts index (6 indexed since start)
94
100
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Post entities into sf_phpunit__aggregated index (6 indexed since start)
@@ -114,6 +120,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
114
120
Cleared sf_phpunit__pages index of Meilisearch\Bundle\Tests\Entity\Page
115
121
Cleared sf_phpunit__self_normalizable index of Meilisearch\Bundle\Tests\Entity\SelfNormalizable
116
122
Cleared sf_phpunit__dummy_custom_groups index of Meilisearch\Bundle\Tests\Entity\DummyCustomGroups
123
+ Cleared sf_phpunit__dynamic_settings index of Meilisearch\Bundle\Tests\Entity\DynamicSettings
117
124
Done!
118
125
119
126
EOD, $ clearOutput );
@@ -132,6 +139,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
132
139
Deleted sf_phpunit__pages
133
140
Deleted sf_phpunit__self_normalizable
134
141
Deleted sf_phpunit__dummy_custom_groups
142
+ Deleted sf_phpunit__dynamic_settings
135
143
Done!
136
144
137
145
EOD, $ clearOutput );
@@ -325,12 +333,20 @@ public function testSearchCreateWithoutIndices(): void
325
333
326
334
$ this ->assertSame (<<<'EOD'
327
335
Creating index sf_phpunit__posts for Meilisearch\Bundle\Tests\Entity\Post
336
+ Settings updated of "sf_phpunit__posts".
337
+ Settings updated of "sf_phpunit__posts".
338
+ Settings updated of "sf_phpunit__posts".
328
339
Creating index sf_phpunit__comments for Meilisearch\Bundle\Tests\Entity\Comment
329
340
Creating index sf_phpunit__tags for Meilisearch\Bundle\Tests\Entity\Tag
330
341
Creating index sf_phpunit__tags for Meilisearch\Bundle\Tests\Entity\Link
331
342
Creating index sf_phpunit__pages for Meilisearch\Bundle\Tests\Entity\Page
332
343
Creating index sf_phpunit__self_normalizable for Meilisearch\Bundle\Tests\Entity\SelfNormalizable
333
344
Creating index sf_phpunit__dummy_custom_groups for Meilisearch\Bundle\Tests\Entity\DummyCustomGroups
345
+ Creating index sf_phpunit__dynamic_settings for Meilisearch\Bundle\Tests\Entity\DynamicSettings
346
+ Settings updated of "sf_phpunit__dynamic_settings".
347
+ Settings updated of "sf_phpunit__dynamic_settings".
348
+ Settings updated of "sf_phpunit__dynamic_settings".
349
+ Settings updated of "sf_phpunit__dynamic_settings".
334
350
Creating index sf_phpunit__aggregated for Meilisearch\Bundle\Tests\Entity\Post
335
351
Creating index sf_phpunit__aggregated for Meilisearch\Bundle\Tests\Entity\Tag
336
352
Done!
@@ -350,6 +366,9 @@ public function testSearchCreateWithIndices(): void
350
366
351
367
$ this ->assertSame (<<<'EOD'
352
368
Creating index sf_phpunit__posts for Meilisearch\Bundle\Tests\Entity\Post
369
+ Settings updated of "sf_phpunit__posts".
370
+ Settings updated of "sf_phpunit__posts".
371
+ Settings updated of "sf_phpunit__posts".
353
372
Done!
354
373
355
374
EOD, $ createOutput );
@@ -437,4 +456,55 @@ public function testImportsDummyWithCustomGroups(): void
437
456
],
438
457
], $ this ->client ->index ('sf_phpunit__dummy_custom_groups ' )->getDocuments ()->getResults ());
439
458
}
459
+
460
+ /**
461
+ * @testWith ["meili:create"]
462
+ * ["meili:import"]
463
+ */
464
+ public function testImportWithDynamicSettings (string $ command ): void
465
+ {
466
+ for ($ i = 0 ; $ i <= 5 ; ++$ i ) {
467
+ $ this ->entityManager ->persist (new DynamicSettings ($ i , "Dynamic $ i " ));
468
+ }
469
+
470
+ $ this ->entityManager ->flush ();
471
+
472
+ $ importCommand = $ this ->application ->find ($ command );
473
+ $ importCommandTester = new CommandTester ($ importCommand );
474
+ $ importCommandTester ->execute (['--indices ' => 'dynamic_settings ' ]);
475
+
476
+ $ importOutput = $ importCommandTester ->getDisplay ();
477
+
478
+ if ('meili:import ' === $ command ) {
479
+ $ this ->assertSame (<<<'EOD'
480
+ Importing for index Meilisearch\Bundle\Tests\Entity\DynamicSettings
481
+ Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\DynamicSettings entities into sf_phpunit__dynamic_settings index (6 indexed since start)
482
+ Settings updated of "sf_phpunit__dynamic_settings".
483
+ Settings updated of "sf_phpunit__dynamic_settings".
484
+ Settings updated of "sf_phpunit__dynamic_settings".
485
+ Settings updated of "sf_phpunit__dynamic_settings".
486
+ Done!
487
+
488
+ EOD, $ importOutput );
489
+ } else {
490
+ $ this ->assertSame (<<<'EOD'
491
+ Creating index sf_phpunit__dynamic_settings for Meilisearch\Bundle\Tests\Entity\DynamicSettings
492
+ Settings updated of "sf_phpunit__dynamic_settings".
493
+ Settings updated of "sf_phpunit__dynamic_settings".
494
+ Settings updated of "sf_phpunit__dynamic_settings".
495
+ Settings updated of "sf_phpunit__dynamic_settings".
496
+ Done!
497
+
498
+ EOD, $ importOutput );
499
+ }
500
+
501
+ $ settings = $ this ->get ('search.client ' )->index ('sf_phpunit__dynamic_settings ' )->getSettings ();
502
+
503
+ $ getSetting = static fn ($ value ) => $ value instanceof \IteratorAggregate ? iterator_to_array ($ value ) : $ value ;
504
+
505
+ self ::assertSame (['publishedAt ' , 'title ' ], $ getSetting ($ settings ['filterableAttributes ' ]));
506
+ self ::assertSame (['title ' ], $ getSetting ($ settings ['searchableAttributes ' ]));
507
+ self ::assertSame (['a ' , 'n ' , 'the ' ], $ getSetting ($ settings ['stopWords ' ]));
508
+ self ::assertSame (['fantastic ' => ['great ' ], 'great ' => ['fantastic ' ]], $ getSetting ($ settings ['synonyms ' ]));
509
+ }
440
510
}
0 commit comments