Skip to content

Commit

Permalink
phpunit deprecation changes made on tests according to sebastianbergm…
Browse files Browse the repository at this point in the history
…ann/phpunit#5062 issue. And also, some changes for warning of code structure
  • Loading branch information
hkulekci committed Feb 24, 2023
1 parent e3890ee commit cf74377
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/Feature/SearchTest.php
Expand Up @@ -143,7 +143,7 @@ public function test_mixed_no_results()
public function test_mixed_cursor()
{
$this->expectException(\Error::class);
$this->expectErrorMessage('Not implemented for MixedSearch');
$this->expectExceptionMessage('Not implemented for MixedSearch');
Artisan::call('scout:import');

$mixed = MixedSearch::search('*')->within(
Expand Down
22 changes: 14 additions & 8 deletions tests/Integration/Engines/ElasticSearchEngineTest.php
Expand Up @@ -78,7 +78,7 @@ public function test_update_throw_exception_on_elasticsearch_error()
$this->engine->update($models);
}

public function test_delete()
public function test_delete(): void
{
$models = Product::all();
$this->engine->update($models);
Expand All @@ -94,14 +94,17 @@ public function test_delete()
],
],
];
$response = $this->elasticsearch->search($params);
$response = $this->elasticsearch->search($params)->asArray();
$this->assertArrayHasKey('hits', $response);
$this->assertArrayHasKey('total', $response['hits']);
$this->assertArrayHasKey('value', $response['hits']['total']);
$this->assertEquals(1, $response['hits']['total']['value']);
foreach ($response['hits']['hits'] as $doc) {
$this->assertEquals($shouldBeNotDeleted->getScoutKey(), $doc['_id']);
}
}

public function test_flush()
public function test_flush(): void
{
$models = Product::all();
$this->engine->update($models);
Expand All @@ -116,11 +119,14 @@ public function test_flush()
],
],
];
$response = $this->elasticsearch->search($params);
$response = $this->elasticsearch->search($params)->asArray();
$this->assertArrayHasKey('hits', $response);
$this->assertArrayHasKey('total', $response['hits']);
$this->assertArrayHasKey('value', $response['hits']['total']);
$this->assertEquals(0, $response['hits']['total']['value']);
}

public function test_map_with_custom_key_name()
public function test_map_with_custom_key_name(): void
{
$this->app['config']['scout.key'] = 'custom_key';
$models = Product::all();
Expand All @@ -134,7 +140,7 @@ public function test_map_with_custom_key_name()
$this->assertEquals($models->map->id->all(), $mappedModels->map->id->all());
}

public function test_lazy_map()
public function test_lazy_map(): void
{
$models = Product::all();
$keys = $models->map(function ($product) {
Expand All @@ -147,10 +153,10 @@ public function test_lazy_map()
$this->assertEquals($models->map->id->all(), $mappedModels->map->id->all());
}

public function test_lazy_map_for_mixed_search()
public function test_lazy_map_for_mixed_search(): void
{
$this->expectErrorMessage('Not implemented for MixedSearch');
$this->expectException(\Error::class);
$this->expectExceptionMessage('Not implemented for MixedSearch');
$models = Product::all();
$keys = $models->map(function ($product) {
return ['_id' => $product->getScoutKey(), '_source' => [
Expand Down

0 comments on commit cf74377

Please sign in to comment.