diff --git a/src/Command/MeilisearchClearCommand.php b/src/Command/MeilisearchClearCommand.php index 5e4660dd..54a35caa 100644 --- a/src/Command/MeilisearchClearCommand.php +++ b/src/Command/MeilisearchClearCommand.php @@ -12,7 +12,7 @@ final class MeilisearchClearCommand extends IndexCommand { public static function getDefaultName(): string { - return 'meili:clear'; + return 'meilisearch:clear|meili:clear'; } public static function getDefaultDescription(): string diff --git a/src/Command/MeilisearchCreateCommand.php b/src/Command/MeilisearchCreateCommand.php index d2c32157..8a253fe4 100644 --- a/src/Command/MeilisearchCreateCommand.php +++ b/src/Command/MeilisearchCreateCommand.php @@ -28,7 +28,7 @@ public function __construct(SearchService $searchService, Client $searchClient) public static function getDefaultName(): string { - return 'meili:create'; + return 'meilisearch:create|meili:create'; } public static function getDefaultDescription(): string diff --git a/src/Command/MeilisearchDeleteCommand.php b/src/Command/MeilisearchDeleteCommand.php index 9fcbb820..04bffc27 100644 --- a/src/Command/MeilisearchDeleteCommand.php +++ b/src/Command/MeilisearchDeleteCommand.php @@ -14,7 +14,7 @@ final class MeilisearchDeleteCommand extends IndexCommand { public static function getDefaultName(): string { - return 'meili:delete'; + return 'meilisearch:delete|meili:delete'; } public static function getDefaultDescription(): string diff --git a/src/Command/MeilisearchImportCommand.php b/src/Command/MeilisearchImportCommand.php index 3d11fdb8..eda43459 100644 --- a/src/Command/MeilisearchImportCommand.php +++ b/src/Command/MeilisearchImportCommand.php @@ -34,7 +34,7 @@ public function __construct(SearchService $searchService, ManagerRegistry $manag public static function getDefaultName(): string { - return 'meili:import'; + return 'meilisearch:import|meili:import'; } public static function getDefaultDescription(): string diff --git a/tests/Integration/CommandsTest.php b/tests/Integration/CommandsTest.php index 6a16bb0d..6ad455ce 100644 --- a/tests/Integration/CommandsTest.php +++ b/tests/Integration/CommandsTest.php @@ -14,9 +14,6 @@ use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -/** - * Class CommandsTest. - */ class CommandsTest extends BaseKernelTestCase { private static string $indexName = 'posts'; @@ -40,7 +37,7 @@ public function testSearchClearUnknownIndex(): void { $unknownIndexName = 'test'; - $command = $this->application->find('meili:clear'); + $command = $this->application->find('meilisearch:clear'); $commandTester = new CommandTester($command); $commandTester->execute([ @@ -65,7 +62,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void $this->createTag(['id' => $i]); } - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $importCommandTester->execute([]); @@ -102,7 +99,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void EOD, $importOutput); - $clearCommand = $this->application->find('meili:clear'); + $clearCommand = $this->application->find('meilisearch:clear'); $clearCommandTester = new CommandTester($clearCommand); $clearCommandTester->execute([]); @@ -122,7 +119,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void EOD, $clearOutput); - $clearCommand = $this->application->find('meili:delete'); + $clearCommand = $this->application->find('meilisearch:delete'); $clearCommandTester = new CommandTester($clearCommand); $clearCommandTester->execute([]); @@ -148,7 +145,7 @@ public function testSearchImportWithCustomBatchSize(): void $this->createPage($i); } - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $importCommandTester->execute([ '--indices' => 'pages', @@ -176,7 +173,7 @@ public function testSearchImportWithCustomResponseTimeout(): void $this->createPage($i); } - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $return = $importCommandTester->execute([ '--indices' => 'pages', @@ -197,7 +194,7 @@ public function testSearchImportWithCustomResponseTimeout(): void } // test if it will work with a bad option - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $return = $importCommandTester->execute([ '--indices' => 'pages', @@ -222,7 +219,7 @@ public function testImportDifferentEntitiesIntoSameIndex(): void $this->createLink(['id' => 60, 'isSponsored' => true]); $this->createLink(['id' => 61, 'isSponsored' => true]); - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $commandTester->execute([ '--indices' => 'tags', @@ -246,7 +243,7 @@ public function testSearchImportAggregator(): void $this->createPost(); } - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $return = $commandTester->execute([ '--indices' => $this->index->getUid(), @@ -265,7 +262,7 @@ public function testSearchImportWithSkipBatches(): void $this->createPage($i); } - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $return = $commandTester->execute([ '--indices' => 'pages', @@ -288,7 +285,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void $this->createPost(); } - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $return = $commandTester->execute([ '--indices' => $this->index->getUid(), // This is the already prefixed name @@ -307,7 +304,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void $this->createPost(); } - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $return = $commandTester->execute([ '--indices' => self::$indexName, // This is the already prefixed name @@ -322,7 +319,7 @@ public function testImportingIndexNameWithAndWithoutPrefix(): void public function testSearchCreateWithoutIndices(): void { - $createCommand = $this->application->find('meili:create'); + $createCommand = $this->application->find('meilisearch:create'); $createCommandTester = new CommandTester($createCommand); $createCommandTester->execute([]); @@ -353,7 +350,7 @@ public function testSearchCreateWithoutIndices(): void public function testSearchCreateWithIndices(): void { - $createCommand = $this->application->find('meili:create'); + $createCommand = $this->application->find('meilisearch:create'); $createCommandTester = new CommandTester($createCommand); $createCommandTester->execute([ '--indices' => 'posts', @@ -373,7 +370,7 @@ public function testSearchCreateWithIndices(): void public function testCreateExecuteIndexCreation(): void { - $createCommand = $this->application->find('meili:create'); + $createCommand = $this->application->find('meilisearch:create'); $createCommandTester = new CommandTester($createCommand); $createCommandTester->execute([]); @@ -388,7 +385,7 @@ public function testImportsSelfNormalizable(): void $this->entityManager->flush(); - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $importCommandTester->execute(['--indices' => 'self_normalizable']); @@ -425,7 +422,7 @@ public function testImportsDummyWithCustomGroups(): void $this->entityManager->flush(); - $importCommand = $this->application->find('meili:import'); + $importCommand = $this->application->find('meilisearch:import'); $importCommandTester = new CommandTester($importCommand); $importCommandTester->execute(['--indices' => 'dummy_custom_groups']); @@ -455,8 +452,8 @@ public function testImportsDummyWithCustomGroups(): void } /** - * @testWith ["meili:create"] - * ["meili:import"] + * @testWith ["meilisearch:create"] + * ["meilisearch:import"] */ public function testImportWithDynamicSettings(string $command): void { @@ -472,7 +469,7 @@ public function testImportWithDynamicSettings(string $command): void $importOutput = $importCommandTester->getDisplay(); - if ('meili:import' === $command) { + if ('meilisearch:import' === $command) { $this->assertSame(<<<'EOD' Importing for index Meilisearch\Bundle\Tests\Entity\DynamicSettings 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 self::assertSame(['a', 'n', 'the'], $getSetting($settings['stopWords'])); self::assertSame(['fantastic' => ['great'], 'great' => ['fantastic']], $getSetting($settings['synonyms'])); } + + /** + * @testWith ["meilisearch:clear", ["meili:clear"]] + * ["meilisearch:create", ["meili:create"]] + * ["meilisearch:delete", ["meili:delete"]] + * ["meilisearch:import", ["meili:import"]] + */ + public function testAliases(string $command, array $expectedAliases): void + { + $command = $this->application->find($command); + + self::assertSame($expectedAliases, $command->getAliases()); + } } diff --git a/tests/Integration/SearchTest.php b/tests/Integration/SearchTest.php index f5a8ddeb..b4f20612 100644 --- a/tests/Integration/SearchTest.php +++ b/tests/Integration/SearchTest.php @@ -55,7 +55,7 @@ public function testSearchImportAggregator(): void $this->createTag(['id' => 99]); - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $commandTester->execute([ '--indices' => $this->index->getUid(), @@ -100,7 +100,7 @@ public function testSearchPagination(): void $testDataTitles[] = $this->createPost()->getTitle(); } - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $commandTester->execute([ '--indices' => $this->index->getUid(), diff --git a/tests/Integration/SettingsTest.php b/tests/Integration/SettingsTest.php index 302c4fac..bbc8c9ca 100644 --- a/tests/Integration/SettingsTest.php +++ b/tests/Integration/SettingsTest.php @@ -42,7 +42,7 @@ public function testUpdateSettings(): void { $index = $this->getPrefix().self::$indexName; - $command = $this->application->find('meili:import'); + $command = $this->application->find('meilisearch:import'); $commandTester = new CommandTester($command); $commandTester->execute([ '--indices' => $index,