14
14
use Symfony \Bundle \FrameworkBundle \Console \Application ;
15
15
use Symfony \Component \Console \Tester \CommandTester ;
16
16
17
- /**
18
- * Class CommandsTest.
19
- */
20
17
class CommandsTest extends BaseKernelTestCase
21
18
{
22
19
private static string $ indexName = 'posts ' ;
@@ -40,7 +37,7 @@ public function testSearchClearUnknownIndex(): void
40
37
{
41
38
$ unknownIndexName = 'test ' ;
42
39
43
- $ command = $ this ->application ->find ('meili :clear ' );
40
+ $ command = $ this ->application ->find ('meilisearch :clear ' );
44
41
$ commandTester = new CommandTester ($ command );
45
42
46
43
$ commandTester ->execute ([
@@ -65,7 +62,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
65
62
$ this ->createTag (['id ' => $ i ]);
66
63
}
67
64
68
- $ importCommand = $ this ->application ->find ('meili :import ' );
65
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
69
66
$ importCommandTester = new CommandTester ($ importCommand );
70
67
$ importCommandTester ->execute ([]);
71
68
@@ -102,7 +99,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
102
99
103
100
EOD, $ importOutput );
104
101
105
- $ clearCommand = $ this ->application ->find ('meili :clear ' );
102
+ $ clearCommand = $ this ->application ->find ('meilisearch :clear ' );
106
103
$ clearCommandTester = new CommandTester ($ clearCommand );
107
104
$ clearCommandTester ->execute ([]);
108
105
@@ -122,7 +119,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
122
119
123
120
EOD, $ clearOutput );
124
121
125
- $ clearCommand = $ this ->application ->find ('meili :delete ' );
122
+ $ clearCommand = $ this ->application ->find ('meilisearch :delete ' );
126
123
$ clearCommandTester = new CommandTester ($ clearCommand );
127
124
$ clearCommandTester ->execute ([]);
128
125
@@ -148,7 +145,7 @@ public function testSearchImportWithCustomBatchSize(): void
148
145
$ this ->createPage ($ i );
149
146
}
150
147
151
- $ importCommand = $ this ->application ->find ('meili :import ' );
148
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
152
149
$ importCommandTester = new CommandTester ($ importCommand );
153
150
$ importCommandTester ->execute ([
154
151
'--indices ' => 'pages ' ,
@@ -176,7 +173,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
176
173
$ this ->createPage ($ i );
177
174
}
178
175
179
- $ importCommand = $ this ->application ->find ('meili :import ' );
176
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
180
177
$ importCommandTester = new CommandTester ($ importCommand );
181
178
$ return = $ importCommandTester ->execute ([
182
179
'--indices ' => 'pages ' ,
@@ -197,7 +194,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
197
194
}
198
195
199
196
// test if it will work with a bad option
200
- $ importCommand = $ this ->application ->find ('meili :import ' );
197
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
201
198
$ importCommandTester = new CommandTester ($ importCommand );
202
199
$ return = $ importCommandTester ->execute ([
203
200
'--indices ' => 'pages ' ,
@@ -222,7 +219,7 @@ public function testImportDifferentEntitiesIntoSameIndex(): void
222
219
$ this ->createLink (['id ' => 60 , 'isSponsored ' => true ]);
223
220
$ this ->createLink (['id ' => 61 , 'isSponsored ' => true ]);
224
221
225
- $ command = $ this ->application ->find ('meili :import ' );
222
+ $ command = $ this ->application ->find ('meilisearch :import ' );
226
223
$ commandTester = new CommandTester ($ command );
227
224
$ commandTester ->execute ([
228
225
'--indices ' => 'tags ' ,
@@ -246,7 +243,7 @@ public function testSearchImportAggregator(): void
246
243
$ this ->createPost ();
247
244
}
248
245
249
- $ command = $ this ->application ->find ('meili :import ' );
246
+ $ command = $ this ->application ->find ('meilisearch :import ' );
250
247
$ commandTester = new CommandTester ($ command );
251
248
$ return = $ commandTester ->execute ([
252
249
'--indices ' => $ this ->index ->getUid (),
@@ -265,7 +262,7 @@ public function testSearchImportWithSkipBatches(): void
265
262
$ this ->createPage ($ i );
266
263
}
267
264
268
- $ command = $ this ->application ->find ('meili :import ' );
265
+ $ command = $ this ->application ->find ('meilisearch :import ' );
269
266
$ commandTester = new CommandTester ($ command );
270
267
$ return = $ commandTester ->execute ([
271
268
'--indices ' => 'pages ' ,
@@ -288,7 +285,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
288
285
$ this ->createPost ();
289
286
}
290
287
291
- $ command = $ this ->application ->find ('meili :import ' );
288
+ $ command = $ this ->application ->find ('meilisearch :import ' );
292
289
$ commandTester = new CommandTester ($ command );
293
290
$ return = $ commandTester ->execute ([
294
291
'--indices ' => $ this ->index ->getUid (), // This is the already prefixed name
@@ -307,7 +304,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
307
304
$ this ->createPost ();
308
305
}
309
306
310
- $ command = $ this ->application ->find ('meili :import ' );
307
+ $ command = $ this ->application ->find ('meilisearch :import ' );
311
308
$ commandTester = new CommandTester ($ command );
312
309
$ return = $ commandTester ->execute ([
313
310
'--indices ' => self ::$ indexName , // This is the already prefixed name
@@ -322,7 +319,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
322
319
323
320
public function testSearchCreateWithoutIndices (): void
324
321
{
325
- $ createCommand = $ this ->application ->find ('meili :create ' );
322
+ $ createCommand = $ this ->application ->find ('meilisearch :create ' );
326
323
$ createCommandTester = new CommandTester ($ createCommand );
327
324
$ createCommandTester ->execute ([]);
328
325
@@ -353,7 +350,7 @@ public function testSearchCreateWithoutIndices(): void
353
350
354
351
public function testSearchCreateWithIndices (): void
355
352
{
356
- $ createCommand = $ this ->application ->find ('meili :create ' );
353
+ $ createCommand = $ this ->application ->find ('meilisearch :create ' );
357
354
$ createCommandTester = new CommandTester ($ createCommand );
358
355
$ createCommandTester ->execute ([
359
356
'--indices ' => 'posts ' ,
@@ -373,7 +370,7 @@ public function testSearchCreateWithIndices(): void
373
370
374
371
public function testCreateExecuteIndexCreation (): void
375
372
{
376
- $ createCommand = $ this ->application ->find ('meili :create ' );
373
+ $ createCommand = $ this ->application ->find ('meilisearch :create ' );
377
374
$ createCommandTester = new CommandTester ($ createCommand );
378
375
$ createCommandTester ->execute ([]);
379
376
@@ -388,7 +385,7 @@ public function testImportsSelfNormalizable(): void
388
385
389
386
$ this ->entityManager ->flush ();
390
387
391
- $ importCommand = $ this ->application ->find ('meili :import ' );
388
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
392
389
$ importCommandTester = new CommandTester ($ importCommand );
393
390
$ importCommandTester ->execute (['--indices ' => 'self_normalizable ' ]);
394
391
@@ -425,7 +422,7 @@ public function testImportsDummyWithCustomGroups(): void
425
422
426
423
$ this ->entityManager ->flush ();
427
424
428
- $ importCommand = $ this ->application ->find ('meili :import ' );
425
+ $ importCommand = $ this ->application ->find ('meilisearch :import ' );
429
426
$ importCommandTester = new CommandTester ($ importCommand );
430
427
$ importCommandTester ->execute (['--indices ' => 'dummy_custom_groups ' ]);
431
428
@@ -455,8 +452,8 @@ public function testImportsDummyWithCustomGroups(): void
455
452
}
456
453
457
454
/**
458
- * @testWith ["meili :create"]
459
- * ["meili :import"]
455
+ * @testWith ["meilisearch :create"]
456
+ * ["meilisearch :import"]
460
457
*/
461
458
public function testImportWithDynamicSettings (string $ command ): void
462
459
{
@@ -472,7 +469,7 @@ public function testImportWithDynamicSettings(string $command): void
472
469
473
470
$ importOutput = $ importCommandTester ->getDisplay ();
474
471
475
- if ('meili :import ' === $ command ) {
472
+ if ('meilisearch :import ' === $ command ) {
476
473
$ this ->assertSame (<<<'EOD'
477
474
Importing for index Meilisearch\Bundle\Tests\Entity\DynamicSettings
478
475
Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\DynamicSettings entities into sf_phpunit__dynamic_settings index (6 indexed since start)
@@ -504,4 +501,17 @@ public function testImportWithDynamicSettings(string $command): void
504
501
self ::assertSame (['a ' , 'n ' , 'the ' ], $ getSetting ($ settings ['stopWords ' ]));
505
502
self ::assertSame (['fantastic ' => ['great ' ], 'great ' => ['fantastic ' ]], $ getSetting ($ settings ['synonyms ' ]));
506
503
}
504
+
505
+ /**
506
+ * @testWith ["meilisearch:clear", ["meili:clear"]]
507
+ * ["meilisearch:create", ["meili:create"]]
508
+ * ["meilisearch:delete", ["meili:delete"]]
509
+ * ["meilisearch:import", ["meili:import"]]
510
+ */
511
+ public function testAliases (string $ command , array $ expectedAliases ): void
512
+ {
513
+ $ command = $ this ->application ->find ($ command );
514
+
515
+ self ::assertSame ($ expectedAliases , $ command ->getAliases ());
516
+ }
507
517
}
0 commit comments