@@ -203,6 +203,32 @@ public function it_handles_any_of_filter()
203
203
$ this ->assertCount (2 , $ filteredDocs );
204
204
}
205
205
206
+ /**
207
+ * @test
208
+ */
209
+ public function it_handles_any_of_filter_with_empty_args ()
210
+ {
211
+ $ collectionName = 'test_any_of_filter_with_empty_args ' ;
212
+ $ this ->documentStore ->addCollection ($ collectionName );
213
+
214
+ $ doc1 = ["foo " => "bar " ];
215
+ $ doc2 = ["foo " => "baz " ];
216
+ $ doc3 = ["foo " => "bat " ];
217
+
218
+ $ docs = [$ doc1 , $ doc2 , $ doc3 ];
219
+
220
+ array_walk ($ docs , function (array $ doc ) use ($ collectionName ) {
221
+ $ this ->documentStore ->addDoc ($ collectionName , Uuid::uuid4 ()->toString (), $ doc );
222
+ });
223
+
224
+ $ filteredDocs = $ this ->documentStore ->filterDocs (
225
+ $ collectionName ,
226
+ new AnyOfFilter ("foo " , [])
227
+ );
228
+
229
+ $ this ->assertCount (0 , $ filteredDocs );
230
+ }
231
+
206
232
/**
207
233
* @test
208
234
*/
@@ -262,6 +288,37 @@ public function it_handles_not_any_of_filter()
262
288
$ this ->assertSame ('baz ' , $ filteredDocs [0 ]['foo ' ]);
263
289
}
264
290
291
+ /**
292
+ * @test
293
+ */
294
+ public function it_handles_not_any_of_filter_with_empty_args ()
295
+ {
296
+ $ collectionName = 'test_not_any_of_filter_with_empty_args ' ;
297
+ $ this ->documentStore ->addCollection ($ collectionName );
298
+
299
+ $ doc1 = ["foo " => "bar " ];
300
+ $ doc2 = ["foo " => "baz " ];
301
+ $ doc3 = ["foo " => "bat " ];
302
+
303
+ $ docs = [$ doc1 , $ doc2 , $ doc3 ];
304
+
305
+ array_walk ($ docs , function (array $ doc ) use ($ collectionName ) {
306
+ $ this ->documentStore ->addDoc ($ collectionName , Uuid::uuid4 ()->toString (), $ doc );
307
+ });
308
+
309
+ $ filteredDocs = $ this ->documentStore ->filterDocs (
310
+ $ collectionName ,
311
+ new NotFilter (new AnyOfFilter ("foo " , []))
312
+ );
313
+
314
+ $ filteredDocs = iterator_to_array ($ filteredDocs );
315
+
316
+ $ this ->assertCount (3 , $ filteredDocs );
317
+
318
+ $ this ->assertSame ('baz ' , $ filteredDocs [1 ]['foo ' ]);
319
+ $ this ->assertSame ('bat ' , $ filteredDocs [2 ]['foo ' ]);
320
+ }
321
+
265
322
/**
266
323
* @test
267
324
*/
@@ -316,6 +373,36 @@ public function it_handles_any_of_doc_id_filter()
316
373
$ this ->assertEquals (['bar ' , 'baz ' ], $ vals );
317
374
}
318
375
376
+ /**
377
+ * @test
378
+ */
379
+ public function it_handles_any_of_doc_id_filter_with_empty_args ()
380
+ {
381
+ $ collectionName = 'test_any_of_doc_id_filter_with_empty_args ' ;
382
+ $ this ->documentStore ->addCollection ($ collectionName );
383
+
384
+ $ firstDocId = Uuid::uuid4 ()->toString ();
385
+ $ secondDocId = Uuid::uuid4 ()->toString ();
386
+ $ thirdDocId = Uuid::uuid4 ()->toString ();
387
+
388
+ $ this ->documentStore ->addDoc ($ collectionName , $ firstDocId , ['foo ' => 'bar ' ]);
389
+ $ this ->documentStore ->addDoc ($ collectionName , $ secondDocId , ['foo ' => 'bat ' ]);
390
+ $ this ->documentStore ->addDoc ($ collectionName , $ thirdDocId , ['foo ' => 'baz ' ]);
391
+
392
+ $ filteredDocs = \iterator_to_array ($ this ->documentStore ->filterDocs (
393
+ $ collectionName ,
394
+ new AnyOfDocIdFilter ([])
395
+ ));
396
+
397
+ $ this ->assertCount (0 , $ filteredDocs );
398
+
399
+ $ vals = array_map (function (array $ doc ) {
400
+ return $ doc ['foo ' ];
401
+ }, $ filteredDocs );
402
+
403
+ $ this ->assertEquals ([], $ vals );
404
+ }
405
+
319
406
/**
320
407
* @test
321
408
*/
@@ -346,6 +433,36 @@ public function it_handles_not_any_of_id_filter()
346
433
$ this ->assertEquals (['bat ' ], $ vals );
347
434
}
348
435
436
+ /**
437
+ * @test
438
+ */
439
+ public function it_handles_not_any_of_id_filter_with_empty_args ()
440
+ {
441
+ $ collectionName = 'test_any_of_doc_id_filter_with_empty_args ' ;
442
+ $ this ->documentStore ->addCollection ($ collectionName );
443
+
444
+ $ firstDocId = Uuid::uuid4 ()->toString ();
445
+ $ secondDocId = Uuid::uuid4 ()->toString ();
446
+ $ thirdDocId = Uuid::uuid4 ()->toString ();
447
+
448
+ $ this ->documentStore ->addDoc ($ collectionName , $ firstDocId , ['foo ' => 'bar ' ]);
449
+ $ this ->documentStore ->addDoc ($ collectionName , $ secondDocId , ['foo ' => 'bat ' ]);
450
+ $ this ->documentStore ->addDoc ($ collectionName , $ thirdDocId , ['foo ' => 'baz ' ]);
451
+
452
+ $ filteredDocs = \iterator_to_array ($ this ->documentStore ->filterDocs (
453
+ $ collectionName ,
454
+ new NotFilter (new AnyOfDocIdFilter ([]))
455
+ ));
456
+
457
+ $ this ->assertCount (3 , $ filteredDocs );
458
+
459
+ $ vals = array_map (function (array $ doc ) {
460
+ return $ doc ['foo ' ];
461
+ }, $ filteredDocs );
462
+
463
+ $ this ->assertEquals (['bar ' , 'bat ' , 'baz ' ], $ vals );
464
+ }
465
+
349
466
/**
350
467
* @test
351
468
*/
0 commit comments