Skip to content

Commit 45aaa24

Browse files
committed
Use meilisearch: prefix for commands
1 parent 85f0717 commit 45aaa24

File tree

7 files changed

+40
-30
lines changed

7 files changed

+40
-30
lines changed

src/Command/MeilisearchClearCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class MeilisearchClearCommand extends IndexCommand
1212
{
1313
public static function getDefaultName(): string
1414
{
15-
return 'meili:clear';
15+
return 'meilisearch:clear|meili:clear';
1616
}
1717

1818
public static function getDefaultDescription(): string

src/Command/MeilisearchCreateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(SearchService $searchService, Client $searchClient)
2828

2929
public static function getDefaultName(): string
3030
{
31-
return 'meili:create';
31+
return 'meilisearch:create|meili:create';
3232
}
3333

3434
public static function getDefaultDescription(): string

src/Command/MeilisearchDeleteCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class MeilisearchDeleteCommand extends IndexCommand
1414
{
1515
public static function getDefaultName(): string
1616
{
17-
return 'meili:delete';
17+
return 'meilisearch:delete|meili:delete';
1818
}
1919

2020
public static function getDefaultDescription(): string

src/Command/MeilisearchImportCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(SearchService $searchService, ManagerRegistry $manag
3434

3535
public static function getDefaultName(): string
3636
{
37-
return 'meili:import';
37+
return 'meilisearch:import|meili:import';
3838
}
3939

4040
public static function getDefaultDescription(): string

tests/Integration/CommandsTest.php

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
use Symfony\Bundle\FrameworkBundle\Console\Application;
1515
use Symfony\Component\Console\Tester\CommandTester;
1616

17-
/**
18-
* Class CommandsTest.
19-
*/
2017
class CommandsTest extends BaseKernelTestCase
2118
{
2219
private static string $indexName = 'posts';
@@ -40,7 +37,7 @@ public function testSearchClearUnknownIndex(): void
4037
{
4138
$unknownIndexName = 'test';
4239

43-
$command = $this->application->find('meili:clear');
40+
$command = $this->application->find('meilisearch:clear');
4441
$commandTester = new CommandTester($command);
4542

4643
$commandTester->execute([
@@ -65,7 +62,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
6562
$this->createTag(['id' => $i]);
6663
}
6764

68-
$importCommand = $this->application->find('meili:import');
65+
$importCommand = $this->application->find('meilisearch:import');
6966
$importCommandTester = new CommandTester($importCommand);
7067
$importCommandTester->execute([]);
7168

@@ -102,7 +99,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
10299

103100
EOD, $importOutput);
104101

105-
$clearCommand = $this->application->find('meili:clear');
102+
$clearCommand = $this->application->find('meilisearch:clear');
106103
$clearCommandTester = new CommandTester($clearCommand);
107104
$clearCommandTester->execute([]);
108105

@@ -122,7 +119,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void
122119

123120
EOD, $clearOutput);
124121

125-
$clearCommand = $this->application->find('meili:delete');
122+
$clearCommand = $this->application->find('meilisearch:delete');
126123
$clearCommandTester = new CommandTester($clearCommand);
127124
$clearCommandTester->execute([]);
128125

@@ -148,7 +145,7 @@ public function testSearchImportWithCustomBatchSize(): void
148145
$this->createPage($i);
149146
}
150147

151-
$importCommand = $this->application->find('meili:import');
148+
$importCommand = $this->application->find('meilisearch:import');
152149
$importCommandTester = new CommandTester($importCommand);
153150
$importCommandTester->execute([
154151
'--indices' => 'pages',
@@ -176,7 +173,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
176173
$this->createPage($i);
177174
}
178175

179-
$importCommand = $this->application->find('meili:import');
176+
$importCommand = $this->application->find('meilisearch:import');
180177
$importCommandTester = new CommandTester($importCommand);
181178
$return = $importCommandTester->execute([
182179
'--indices' => 'pages',
@@ -197,7 +194,7 @@ public function testSearchImportWithCustomResponseTimeout(): void
197194
}
198195

199196
// test if it will work with a bad option
200-
$importCommand = $this->application->find('meili:import');
197+
$importCommand = $this->application->find('meilisearch:import');
201198
$importCommandTester = new CommandTester($importCommand);
202199
$return = $importCommandTester->execute([
203200
'--indices' => 'pages',
@@ -222,7 +219,7 @@ public function testImportDifferentEntitiesIntoSameIndex(): void
222219
$this->createLink(['id' => 60, 'isSponsored' => true]);
223220
$this->createLink(['id' => 61, 'isSponsored' => true]);
224221

225-
$command = $this->application->find('meili:import');
222+
$command = $this->application->find('meilisearch:import');
226223
$commandTester = new CommandTester($command);
227224
$commandTester->execute([
228225
'--indices' => 'tags',
@@ -246,7 +243,7 @@ public function testSearchImportAggregator(): void
246243
$this->createPost();
247244
}
248245

249-
$command = $this->application->find('meili:import');
246+
$command = $this->application->find('meilisearch:import');
250247
$commandTester = new CommandTester($command);
251248
$return = $commandTester->execute([
252249
'--indices' => $this->index->getUid(),
@@ -265,7 +262,7 @@ public function testSearchImportWithSkipBatches(): void
265262
$this->createPage($i);
266263
}
267264

268-
$command = $this->application->find('meili:import');
265+
$command = $this->application->find('meilisearch:import');
269266
$commandTester = new CommandTester($command);
270267
$return = $commandTester->execute([
271268
'--indices' => 'pages',
@@ -288,7 +285,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
288285
$this->createPost();
289286
}
290287

291-
$command = $this->application->find('meili:import');
288+
$command = $this->application->find('meilisearch:import');
292289
$commandTester = new CommandTester($command);
293290
$return = $commandTester->execute([
294291
'--indices' => $this->index->getUid(), // This is the already prefixed name
@@ -307,7 +304,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
307304
$this->createPost();
308305
}
309306

310-
$command = $this->application->find('meili:import');
307+
$command = $this->application->find('meilisearch:import');
311308
$commandTester = new CommandTester($command);
312309
$return = $commandTester->execute([
313310
'--indices' => self::$indexName, // This is the already prefixed name
@@ -322,7 +319,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void
322319

323320
public function testSearchCreateWithoutIndices(): void
324321
{
325-
$createCommand = $this->application->find('meili:create');
322+
$createCommand = $this->application->find('meilisearch:create');
326323
$createCommandTester = new CommandTester($createCommand);
327324
$createCommandTester->execute([]);
328325

@@ -353,7 +350,7 @@ public function testSearchCreateWithoutIndices(): void
353350

354351
public function testSearchCreateWithIndices(): void
355352
{
356-
$createCommand = $this->application->find('meili:create');
353+
$createCommand = $this->application->find('meilisearch:create');
357354
$createCommandTester = new CommandTester($createCommand);
358355
$createCommandTester->execute([
359356
'--indices' => 'posts',
@@ -373,7 +370,7 @@ public function testSearchCreateWithIndices(): void
373370

374371
public function testCreateExecuteIndexCreation(): void
375372
{
376-
$createCommand = $this->application->find('meili:create');
373+
$createCommand = $this->application->find('meilisearch:create');
377374
$createCommandTester = new CommandTester($createCommand);
378375
$createCommandTester->execute([]);
379376

@@ -388,7 +385,7 @@ public function testImportsSelfNormalizable(): void
388385

389386
$this->entityManager->flush();
390387

391-
$importCommand = $this->application->find('meili:import');
388+
$importCommand = $this->application->find('meilisearch:import');
392389
$importCommandTester = new CommandTester($importCommand);
393390
$importCommandTester->execute(['--indices' => 'self_normalizable']);
394391

@@ -425,7 +422,7 @@ public function testImportsDummyWithCustomGroups(): void
425422

426423
$this->entityManager->flush();
427424

428-
$importCommand = $this->application->find('meili:import');
425+
$importCommand = $this->application->find('meilisearch:import');
429426
$importCommandTester = new CommandTester($importCommand);
430427
$importCommandTester->execute(['--indices' => 'dummy_custom_groups']);
431428

@@ -455,8 +452,8 @@ public function testImportsDummyWithCustomGroups(): void
455452
}
456453

457454
/**
458-
* @testWith ["meili:create"]
459-
* ["meili:import"]
455+
* @testWith ["meilisearch:create"]
456+
* ["meilisearch:import"]
460457
*/
461458
public function testImportWithDynamicSettings(string $command): void
462459
{
@@ -472,7 +469,7 @@ public function testImportWithDynamicSettings(string $command): void
472469

473470
$importOutput = $importCommandTester->getDisplay();
474471

475-
if ('meili:import' === $command) {
472+
if ('meilisearch:import' === $command) {
476473
$this->assertSame(<<<'EOD'
477474
Importing for index Meilisearch\Bundle\Tests\Entity\DynamicSettings
478475
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
504501
self::assertSame(['a', 'n', 'the'], $getSetting($settings['stopWords']));
505502
self::assertSame(['fantastic' => ['great'], 'great' => ['fantastic']], $getSetting($settings['synonyms']));
506503
}
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+
}
507517
}

tests/Integration/SearchTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testSearchImportAggregator(): void
5555

5656
$this->createTag(['id' => 99]);
5757

58-
$command = $this->application->find('meili:import');
58+
$command = $this->application->find('meilisearch:import');
5959
$commandTester = new CommandTester($command);
6060
$commandTester->execute([
6161
'--indices' => $this->index->getUid(),
@@ -100,7 +100,7 @@ public function testSearchPagination(): void
100100
$testDataTitles[] = $this->createPost()->getTitle();
101101
}
102102

103-
$command = $this->application->find('meili:import');
103+
$command = $this->application->find('meilisearch:import');
104104
$commandTester = new CommandTester($command);
105105
$commandTester->execute([
106106
'--indices' => $this->index->getUid(),

tests/Integration/SettingsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testUpdateSettings(): void
4242
{
4343
$index = $this->getPrefix().self::$indexName;
4444

45-
$command = $this->application->find('meili:import');
45+
$command = $this->application->find('meilisearch:import');
4646
$commandTester = new CommandTester($command);
4747
$commandTester->execute([
4848
'--indices' => $index,

0 commit comments

Comments
 (0)