diff --git a/src/Manticoresearch/Client.php b/src/Manticoresearch/Client.php index 7a9c2499..1e7952e4 100755 --- a/src/Manticoresearch/Client.php +++ b/src/Manticoresearch/Client.php @@ -421,4 +421,12 @@ public function request(Request $request, array $params = []): Response { public function getLastResponse(): Response { return $this->lastResponse; } + + /* + * + * @return void + */ + public function unsetLastResponse(): void { + $this->lastResponse = new Response([], null, []); + } } diff --git a/test/Manticoresearch/ClientTest.php b/test/Manticoresearch/ClientTest.php index 3b6871ec..cb9b231b 100644 --- a/test/Manticoresearch/ClientTest.php +++ b/test/Manticoresearch/ClientTest.php @@ -167,4 +167,27 @@ public function testGetLastResponse() { $lastResponse = $client->getLastResponse()->getResponse(); $this->assertEquals($result, $lastResponse); } + public function testUnsetLastResponse() { + $helper = new PopulateHelperTest(); + $helper->populateForKeywords(); + $client = $helper->getClient(); + + $payload = [ + 'body' => [ + 'index' => 'products', + 'query' => [ + 'match' => ['*' => 'broken'], + ], + ], + ]; + + $result = $client->search($payload); + $lastResponse = $client->getLastResponse()->getResponse(); + $this->assertEquals($result, $lastResponse); + + $client->unsetLastResponse(); + + $lastResponse = $client->getLastResponse()->getResponse(); + $this->assertEquals([], $lastResponse); + } } diff --git a/test/Manticoresearch/Endpoints/InsertTest.php b/test/Manticoresearch/Endpoints/InsertTest.php index 887a2676..20c1785c 100644 --- a/test/Manticoresearch/Endpoints/InsertTest.php +++ b/test/Manticoresearch/Endpoints/InsertTest.php @@ -34,11 +34,12 @@ public function testInsert() { ], ]; $response = $client->insert(['body' => $doc]); + unset($response['_index']); + unset($response['table']); // assert inserted $this->assertEquals( [ - '_index' => 'products', '_id' => 1001, 'created' => true, 'result' => 'created',