@@ -456,6 +456,46 @@ public function it_can_be_filtered_using_where_in()
456456 $ this ->assertEquals (2 , $ results ['hits ' ][0 ]['scoutKey ' ]);
457457 }
458458
459+ /** @test */
460+ public function it_can_be_filtered_using_where_in_array ()
461+ {
462+ $ engine = new ArrayEngine (new ArrayStore ());
463+ $ engine ->update (Collection::make ([
464+ new SearchableModel (['foo ' => 'bar ' , 'x ' => ['x ' , 'y ' ], 'scoutKey ' => 1 ]),
465+ new SearchableModel (['foo ' => 'baz ' , 'x ' => ['x ' ], 'scoutKey ' => 2 ]),
466+ new SearchableModel (['foo ' => 'bax ' , 'x ' => ['z ' ], 'scoutKey ' => 3 ]),
467+ ]));
468+
469+ $ builder = new Builder (new SearchableModel (), null );
470+ $ builder ->whereIns = [
471+ 'x ' => ['x ' , 'y ' ]
472+ ];
473+ $ results = $ engine ->search ($ builder );
474+
475+ $ this ->assertCount (2 , $ results ['hits ' ]);
476+ $ this ->assertEquals ([2 , 1 ], array_column ($ results ['hits ' ], 'scoutKey ' ));
477+ }
478+
479+ /** @test */
480+ public function it_can_be_filtered_using_where_in_collection ()
481+ {
482+ $ engine = new ArrayEngine (new ArrayStore ());
483+ $ engine ->update (Collection::make ([
484+ new SearchableModel (['foo ' => 'bar ' , 'x ' => collect (['x ' , 'y ' ]), 'scoutKey ' => 1 ]),
485+ new SearchableModel (['foo ' => 'baz ' , 'x ' => collect (['x ' ]), 'scoutKey ' => 2 ]),
486+ new SearchableModel (['foo ' => 'bax ' , 'x ' => collect (['z ' ]), 'scoutKey ' => 3 ]),
487+ ]));
488+
489+ $ builder = new Builder (new SearchableModel (), null );
490+ $ builder ->whereIns = [
491+ 'x ' => ['x ' , 'y ' ]
492+ ];
493+ $ results = $ engine ->search ($ builder );
494+
495+ $ this ->assertCount (2 , $ results ['hits ' ]);
496+ $ this ->assertEquals ([2 , 1 ], array_column ($ results ['hits ' ], 'scoutKey ' ));
497+ }
498+
459499 /** @test */
460500 public function it_can_be_filtered_using_where_not_in ()
461501 {
0 commit comments