Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use meilisearch: prefix for commands #289

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Command/MeilisearchClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MeilisearchCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MeilisearchDeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Command/MeilisearchImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 33 additions & 23 deletions tests/Integration/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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([
Expand All @@ -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([]);

Expand Down Expand Up @@ -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([]);

Expand All @@ -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([]);

Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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(),
Expand All @@ -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',
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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([]);

Expand Down Expand Up @@ -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',
Expand All @@ -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([]);

Expand All @@ -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']);

Expand Down Expand Up @@ -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']);

Expand Down Expand Up @@ -455,8 +452,8 @@ public function testImportsDummyWithCustomGroups(): void
}

/**
* @testWith ["meili:create"]
* ["meili:import"]
* @testWith ["meilisearch:create"]
* ["meilisearch:import"]
*/
public function testImportWithDynamicSettings(string $command): void
{
Expand All @@ -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)
Expand Down Expand Up @@ -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());
}
}
4 changes: 2 additions & 2 deletions tests/Integration/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading