Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Rename indexName to indexUid
Browse files Browse the repository at this point in the history
  • Loading branch information
mmachatschek committed Feb 26, 2021
1 parent 386874b commit 42dc48d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions tests/Feature/MeilisearchConsoleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,30 @@ public function nameArgumentIsRequired()
/** @test */
public function indexCanBeCreatedAndDeleted()
{
$indexName = $this->getPrefixedIndexName('testindex');
$indexUid = $this->getPrefixedIndexUid('testindex');

$this->artisan('scout:index', [
'name' => $indexName,
'name' => $indexUid,
])
->expectsOutput('Index "'.$indexName.'" created.')
->expectsOutput('Index "'.$indexUid.'" created.')
->assertExitCode(0)
->run();

$indexResponse = resolve(Client::class)->index($indexName)->fetchRawInfo();
$indexResponse = resolve(Client::class)->index($indexUid)->fetchRawInfo();

$this->assertIsArray($indexResponse);
$this->assertSame($indexName, $indexResponse['uid']);
$this->assertSame($indexUid, $indexResponse['uid']);

$this->artisan('scout:index', [
'name' => $indexName,
'name' => $indexUid,
'--delete' => true,
])
->expectsOutput('Index "'.$indexName.'" deleted.')
->expectsOutput('Index "'.$indexUid.'" deleted.')
->assertExitCode(0)
->run();

try {
resolve(Client::class)->index($indexName)->fetchRawInfo();
resolve(Client::class)->index($indexUid)->fetchRawInfo();
$this->fail('Exception should be thrown that index doesn\'t exist!');
} catch (HTTPRequestException $exception) {
$this->assertTrue(true);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ protected function getEnvironmentSetUp($app)
config()->set('scout.prefix', $this->getPrefix());
}

protected function getPrefixedIndexName(string $indexName)
protected function getPrefixedIndexUid(string $indexUid)
{
return sprintf('%s_%s', $this->getPrefix(), $indexName);
return sprintf('%s_%s', $this->getPrefix(), $indexUid);
}

protected function getPrefix()
Expand Down
18 changes: 9 additions & 9 deletions tests/Unit/MeilisearchConsoleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ class MeilisearchConsoleCommandTest extends TestCase
public function commandCreatesIndex()
{
$client = $this->mock(Client::class);
$client->expects('createIndex')->with($indexName = 'testindex', [])->andReturn(m::mock(Indexes::class));
$client->expects('createIndex')->with($indexUid = 'testindex', [])->andReturn(m::mock(Indexes::class));

$engineManager = $this->mock(EngineManager::class);
$engineManager->shouldReceive('engine')->with('meilisearch')->andReturn(new MeilisearchEngine(
$client
));

$this->artisan('scout:index', [
'name' => $indexName,
'name' => $indexUid,
])
->expectsOutput('Index "'.$indexName.'" created.')
->expectsOutput('Index "'.$indexUid.'" created.')
->assertExitCode(0)
->run();
}
Expand All @@ -37,7 +37,7 @@ public function keyParameterSetsPrimaryKeyOption()
$client = $this->mock(Client::class);
$client
->expects('createIndex')
->with($indexName = 'testindex', ['primaryKey' => $testPrimaryKey = 'foobar'])
->with($indexUid = 'testindex', ['primaryKey' => $testPrimaryKey = 'foobar'])
->andReturn(m::mock(Indexes::class));

$engineManager = $this->mock(EngineManager::class);
Expand All @@ -46,10 +46,10 @@ public function keyParameterSetsPrimaryKeyOption()
));

$this->artisan('scout:index', [
'name' => $indexName,
'name' => $indexUid,
'--key' => $testPrimaryKey,
])
->expectsOutput('Index "'.$indexName.'" created.')
->expectsOutput('Index "'.$indexUid.'" created.')
->assertExitCode(0)
->run();
}
Expand All @@ -58,18 +58,18 @@ public function keyParameterSetsPrimaryKeyOption()
public function deleteParameterDeletesIndex()
{
$client = $this->mock(Client::class);
$client->expects('deleteIndex')->with($indexName = 'testindex')->andReturn([]);
$client->expects('deleteIndex')->with($indexUid = 'testindex')->andReturn([]);

$engineManager = $this->mock(EngineManager::class);
$engineManager->shouldReceive('engine')->with('meilisearch')->andReturn(new MeilisearchEngine(
$client
));

$this->artisan('scout:index', [
'name' => $indexName,
'name' => $indexUid,
'--delete' => true,
])
->expectsOutput('Index "'.$indexName.'" deleted.')
->expectsOutput('Index "'.$indexUid.'" deleted.')
->assertExitCode(0)
->run();
}
Expand Down

0 comments on commit 42dc48d

Please sign in to comment.