Skip to content

Commit 852ce58

Browse files
committed
fix: Use iterator_to_array in every test, to trigger the generator function
1 parent 8a4a3c1 commit 852ce58

File tree

11 files changed

+17
-20
lines changed

11 files changed

+17
-20
lines changed

src/store/tests/Bridge/Azure/SearchStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function testQueryFailure()
247247
$this->expectExceptionMessage('HTTP 400 returned');
248248
$this->expectExceptionCode(400);
249249

250-
$store->query(new Vector([0.1, 0.2, 0.3]));
250+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
251251
}
252252

253253
public function testQueryWithNullVector()

src/store/tests/Bridge/Cloudflare/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function testStoreCannotQueryOnInvalidResponse()
197197
$this->expectException(ClientException::class);
198198
$this->expectExceptionMessage('HTTP 400 returned for "https://api.cloudflare.com/client/v4/accounts/foo/vectorize/v2/indexes/random/query".');
199199
$this->expectExceptionCode(400);
200-
$store->query(new Vector([0.1, 0.2, 0.3]));
200+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
201201
}
202202

203203
public function testStoreCanQuery()

src/store/tests/Bridge/Manticore/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function testStoreCannotQueryOnInvalidResponse()
159159
$this->expectException(ClientException::class);
160160
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:9308/search".');
161161
$this->expectExceptionCode(400);
162-
$store->query(new Vector([0.1, 0.2, 0.3]));
162+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
163163
}
164164

165165
public function testStoreCanQuery()

src/store/tests/Bridge/Meilisearch/StoreTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function testStoreCannotQueryOnInvalidResponse()
186186
$this->expectException(ClientException::class);
187187
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:7700/indexes/test/search".');
188188
$this->expectExceptionCode(400);
189-
$store->query(new Vector([0.1, 0.2, 0.3]));
189+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
190190
}
191191

192192
public function testStoreCanQuery()
@@ -328,7 +328,7 @@ public function testQueryUsesDefaultSemanticRatio()
328328
$store = new Store($httpClient, 'http://localhost:7700', 'key', 'index', semanticRatio: 0.7);
329329

330330
$vector = new Vector([0.1, 0.2, 0.3]);
331-
$store->query($vector);
331+
iterator_to_array($store->query($vector));
332332

333333
$request = $httpClient->getRequestsCount() > 0 ? $responses[0]->getRequestOptions() : null;
334334
$this->assertNotNull($request);
@@ -348,8 +348,7 @@ public function testQueryCanOverrideSemanticRatio()
348348
$httpClient = new MockHttpClient($responses);
349349
$store = new Store($httpClient, 'http://localhost:7700', 'key', 'index', semanticRatio: 0.5);
350350

351-
$vector = new Vector([0.1, 0.2, 0.3]);
352-
$store->query($vector, ['semanticRatio' => 0.2]);
351+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3]), ['semanticRatio' => 0.2]));
353352

354353
$request = $responses[0]->getRequestOptions();
355354
$body = json_decode($request['body'], true);
@@ -366,7 +365,7 @@ public function testQueryThrowsExceptionForInvalidSemanticRatioOption()
366365
$store = new Store($httpClient, 'http://localhost:7700', 'key', 'index');
367366

368367
$vector = new Vector([0.1, 0.2, 0.3]);
369-
$store->query($vector, ['semanticRatio' => 2.0]);
368+
iterator_to_array($store->query($vector, ['semanticRatio' => 2.0]));
370369
}
371370

372371
public function testQueryWithPureKeywordSearch()
@@ -414,7 +413,7 @@ public function testQueryWithBalancedHybridSearch()
414413
$store = new Store($httpClient, 'http://localhost:7700', 'key', 'index', semanticRatio: 0.5);
415414

416415
$vector = new Vector([0.1, 0.2, 0.3]);
417-
$store->query($vector);
416+
iterator_to_array($store->query($vector));
418417

419418
$request = $responses[0]->getRequestOptions();
420419
$body = json_decode($request['body'], true);

src/store/tests/Bridge/Milvus/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function testStoreCannotQueryOnInvalidResponse()
195195
$this->expectException(ClientException::class);
196196
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:19530/v2/vectordb/entities/search".');
197197
$this->expectExceptionCode(400);
198-
$store->query(new Vector([0.1, 0.2, 0.3]));
198+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
199199
}
200200

201201
public function testStoreCanQuery()

src/store/tests/Bridge/Qdrant/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function testStoreCannotQueryOnInvalidResponse()
227227
$this->expectException(ClientException::class);
228228
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:6333/collections/test/points/query".');
229229
$this->expectExceptionCode(400);
230-
$store->query(new Vector([0.1, 0.2, 0.3]));
230+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
231231
}
232232

233233
public function testStoreCanQuery()

src/store/tests/Bridge/Redis/StoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public function testQueryFailureThrowsRuntimeException()
319319
$this->expectException(RuntimeException::class);
320320
$this->expectExceptionMessage('Failed to execute query: "Search failed".');
321321

322-
$store->query(new Vector([0.1, 0.2, 0.3]));
322+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
323323
}
324324

325325
public function testInitialize()
@@ -463,7 +463,7 @@ public function testToRedisVectorConversion()
463463
)
464464
->willReturn([0]);
465465

466-
$store->query(new Vector([0.1, 0.2, 0.3]));
466+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
467467
}
468468

469469
public function testQueryEmptyResults()

src/store/tests/Bridge/Supabase/StoreTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testQueryThrowsExceptionOnHttpError()
9494

9595
$this->expectException(RuntimeException::class);
9696
$this->expectExceptionMessage('Supabase query failed: Query failed');
97-
$store->query($queryVector);
97+
iterator_to_array($store->query($queryVector));
9898
}
9999

100100
public function testQueryWithDefaultOptions()
@@ -121,12 +121,10 @@ public function testQueryThrowsExceptionForWrongVectorDimension()
121121
{
122122
$httpClient = new MockHttpClient(new JsonMockResponse([]));
123123
$store = $this->createStore($httpClient);
124-
$wrongDimensionVector = new Vector([1.0]);
125-
$store = $this->createStore($httpClient);
126124

127125
$this->expectException(\InvalidArgumentException::class);
128126
$this->expectExceptionMessage('Vector dimension mismatch: expected 2');
129-
$store->query($wrongDimensionVector);
127+
iterator_to_array($store->query(new Vector([1.0])));
130128
}
131129

132130
public function testQuerySuccess()

src/store/tests/Bridge/SurrealDb/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public function testStoreCannotQueryOnInvalidResponse()
326326
$this->expectException(ClientException::class);
327327
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:8000/sql".');
328328
$this->expectExceptionCode(400);
329-
$store->query(new Vector(array_fill(0, 1275, 0.1)));
329+
iterator_to_array($store->query(new Vector(array_fill(0, 1275, 0.1))));
330330
}
331331

332332
public function testStoreCanQueryOnValidEmbeddings()

src/store/tests/Bridge/Typesense/StoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function testStoreCannotQueryOnInvalidResponse()
168168
$this->expectException(ClientException::class);
169169
$this->expectExceptionMessage('HTTP 400 returned for "http://127.0.0.1:8108/multi_search".');
170170
$this->expectExceptionCode(400);
171-
$store->query(new Vector([0.1, 0.2, 0.3]));
171+
iterator_to_array($store->query(new Vector([0.1, 0.2, 0.3])));
172172
}
173173

174174
public function testStoreCanQuery()

0 commit comments

Comments
 (0)