diff --git a/README.md b/README.md index 89049bb3..ee9c3a67 100644 --- a/README.md +++ b/README.md @@ -215,7 +215,7 @@ $results = Product::search('zonga', function($client, $body) { $body->addAggregation($minPriceAggregation); $body->addAggregation($brandTermAggregation); - return $client->search(['index' => 'products', 'body' => $body->toArray()]); + return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray(); })->raw(); ``` diff --git a/composer.json b/composer.json index 993594b4..fc4abd96 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "laravel/legacy-factories": "^1.0", "nunomaduro/larastan": "~0.6", "orchestra/testbench": "^6.18", + "php-http/guzzle7-adapter": "^1.0", "phpunit/phpunit": "~9.4.0" }, "autoload-dev": { diff --git a/tests/Feature/ElasticSearchEngineTest.php b/tests/Feature/ElasticSearchEngineTest.php index edb258ae..e520831e 100644 --- a/tests/Feature/ElasticSearchEngineTest.php +++ b/tests/Feature/ElasticSearchEngineTest.php @@ -22,8 +22,10 @@ public function test_pass_empty_response(): void Artisan::call('scout:import'); $results = Product::search('Quia', static function ($client, $body) { - return $client->search(['index' => 'products', 'body' => $body->toArray()]); + return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray(); })->raw(); + + $this->assertIsArray($results); $this->assertEmpty($results['hits']['hits']); } @@ -39,9 +41,10 @@ public function test_pass_with_response(): void Artisan::call('scout:import'); $results = Product::search('iphone', static function ($client, $body) { - return $client->search(['index' => 'products', 'body' => $body->toArray()]); + return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray(); })->raw(); + $this->assertIsArray($results); $this->assertNotEmpty($results['hits']['hits']); } }