Skip to content

Commit 4aed0a4

Browse files
author
Holger Lösken
committed
Add additional test for calling import with and without prefix
1 parent b9f8a9a commit 4aed0a4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/TestCase/CommandsTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,46 @@ public function testSearchImportAggregator()
9898
$this->assertStringContainsString('Done!', $output);
9999
$this->assertSame(0, $return);
100100
}
101+
102+
public function testImportingIndexNameWithAndWithoutPrefix(): void
103+
{
104+
for ($i = 0; $i <= 5; ++$i) {
105+
$this->createPost();
106+
}
107+
108+
$command = $this->application->find('meili:import');
109+
$commandTester = new CommandTester($command);
110+
$return = $commandTester->execute([
111+
'--indices' => $this->index->getUid(), // This is the already prefixed name
112+
]);
113+
114+
$output = $commandTester->getDisplay();
115+
$this->assertStringContainsString('Importing for index MeiliSearch\Bundle\Test\Entity\Post', $output);
116+
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' MeiliSearch\Bundle\Test\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
117+
$this->assertStringContainsString('Done!', $output);
118+
$this->assertSame(0, $return);
119+
120+
// Reset database and MS indexes
121+
parent::setUp();
122+
123+
for ($i = 0; $i <= 5; ++$i) {
124+
$this->createPost();
125+
}
126+
127+
$command = $this->application->find('meili:import');
128+
$commandTester = new CommandTester($command);
129+
$return = $commandTester->execute([
130+
'--indices' => self::$indexName, // This is the already prefixed name
131+
]);
132+
133+
// Check that the same index like above is created with the same name, although we passed it
134+
// in without the prefix
135+
$this->assertInstanceOf(Indexes::class, $this->index->fetchInfo());
136+
137+
$output = $commandTester->getDisplay();
138+
$this->assertStringContainsString('Importing for index MeiliSearch\Bundle\Test\Entity\Post', $output);
139+
$this->assertStringContainsString('Indexed '.$i.' / '.$i.' MeiliSearch\Bundle\Test\Entity\Post entities into sf_phpunit__'.self::$indexName.' index', $output);
140+
$this->assertStringContainsString('Done!', $output);
141+
$this->assertSame(0, $return);
142+
}
101143
}

0 commit comments

Comments
 (0)