@@ -180,6 +180,85 @@ public function search_with_order_by()
180
180
$ engine ->search ($ builder );
181
181
}
182
182
183
+ /**
184
+ * @test
185
+ */
186
+ public function search_with_queryCallback ()
187
+ {
188
+ [$ engine , $ db ] = $ this ->getEngine ();
189
+
190
+ $ skip = 0 ;
191
+ $ limit = 5 ;
192
+ $ table = $ this ->setDbExpectations ($ db );
193
+
194
+ $ table ->shouldReceive ('skip ' )->with ($ skip )->andReturnSelf ()
195
+ ->shouldReceive ('limit ' )->with ($ limit )->andReturnSelf ()
196
+ ->shouldReceive ('where ' )->with ('bar ' , 1 )->andReturnSelf ()
197
+ ->shouldReceive ('where ' )->with ('baz ' , 'qux ' )
198
+ ->shouldReceive ('getBindings ' )->andReturn ([null , 'foo ' , 1 , 'qux ' ]);
199
+
200
+ $ db ->shouldReceive ('select ' )
201
+ ->with (null , $ table ->getBindings ())
202
+ ->once ();
203
+
204
+ $ builder = new Builder (new TestModel , 'foo ' );
205
+ $ builder ->query (function ($ q ) {
206
+ $ q ->where ('bar ' , 1 )
207
+ ->where ('baz ' , 'qux ' )
208
+ ->take (5 );
209
+ });
210
+
211
+ $ engine ->search ($ builder );
212
+ }
213
+
214
+ /**
215
+ * @test
216
+ */
217
+ public function search_with_whereIn ()
218
+ {
219
+ [$ engine , $ db ] = $ this ->getEngine ();
220
+
221
+ $ skip = 0 ;
222
+ $ limit = 5 ;
223
+ $ table = $ this ->setDbExpectations ($ db );
224
+
225
+ $ table ->shouldReceive ('whereIn ' )->with ('bar ' , [1 ])->andReturnSelf ()
226
+ ->shouldReceive ('getBindings ' )->andReturn ([null , 'foo ' , [1 ]]);
227
+
228
+ $ db ->shouldReceive ('select ' )
229
+ ->with (null , $ table ->getBindings ())
230
+ ->once ();
231
+
232
+ $ builder = new Builder (new TestModel , 'foo ' );
233
+ $ builder ->whereIn ('bar ' , [1 ]);
234
+
235
+ $ engine ->search ($ builder );
236
+ }
237
+
238
+ /**
239
+ * @test
240
+ */
241
+ public function search_with_whereNotIn ()
242
+ {
243
+ [$ engine , $ db ] = $ this ->getEngine ();
244
+
245
+ $ skip = 0 ;
246
+ $ limit = 5 ;
247
+ $ table = $ this ->setDbExpectations ($ db );
248
+
249
+ $ table ->shouldReceive ('whereNotIn ' )->with ('bar ' , [1 ])->andReturnSelf ()
250
+ ->shouldReceive ('getBindings ' )->andReturn ([null , 'foo ' , [1 ]]);
251
+
252
+ $ db ->shouldReceive ('select ' )
253
+ ->with (null , $ table ->getBindings ())
254
+ ->once ();
255
+
256
+ $ builder = new Builder (new TestModel , 'foo ' );
257
+ $ builder ->whereNotIn ('bar ' , [1 ]);
258
+
259
+ $ engine ->search ($ builder );
260
+ }
261
+
183
262
/**
184
263
* @test
185
264
*/
0 commit comments