@@ -297,6 +297,46 @@ public function testDeleteWhere(): void
297
297
$ this ->assertSame (0 , User::count ());
298
298
}
299
299
300
+ public function testDeleteWhereMultiple (): void
301
+ {
302
+ $ this ->cleanupUsers ();
303
+ $ this ->assertSame (0 , User::count ());
304
+ $ user1 = User::create (
305
+ '5c8169b1-d6ef-4415-8c39-e1664df8b954 ' ,
306
+ 'Gwénola ' ,
307
+ 'Etheve ' ,
308
+ null
309
+ );
310
+ $ this ->assertTrue ($ user1 ->save ());
311
+ $ user2 = User::create (
312
+ '874d1aa5-4db3-4953-88dd-2dd58a298d3e ' ,
313
+ 'William ' ,
314
+ 'Desportes ' ,
315
+ null
316
+ );
317
+
318
+ $ this ->assertTrue ($ user2 ->save ());
319
+ $ this ->assertSame (2 , User::count ());
320
+ $ this ->assertNotNull (User::findById ('5c8169b1-d6ef-4415-8c39-e1664df8b954 ' ));
321
+ $ this ->assertNotNull (User::findById ('874d1aa5-4db3-4953-88dd-2dd58a298d3e ' ));
322
+ $ this ->emptyQueries ();
323
+ User::deleteWhere (
324
+ [
325
+ 'first_name ' => ['William ' , 'Gwénola ' ],
326
+ ]
327
+ );
328
+ $ this ->assertWasQuery (
329
+ 'DELETE FROM `users` WHERE `first_name` IN(?,?); ' ,
330
+ [
331
+ 'William ' ,
332
+ 'Gwénola ' ,
333
+ ]
334
+ );
335
+ $ this ->assertNull (User::findById ('874d1aa5-4db3-4953-88dd-2dd58a298d3e ' ));
336
+ $ this ->assertNull (User::findById ('5c8169b1-d6ef-4415-8c39-e1664df8b954 ' ));
337
+ $ this ->assertSame (0 , User::count ());
338
+ }
339
+
300
340
public function testRefreshDeleted (): void
301
341
{
302
342
$ this ->cleanupUsers ();
@@ -314,6 +354,37 @@ public function testRefreshDeleted(): void
314
354
$ this ->assertSame (0 , User::count ());
315
355
}
316
356
357
+ public function testFindWhere (): void
358
+ {
359
+ $ this ->cleanupUsers ();
360
+ $ this ->assertSame (0 , User::count ());
361
+ $ user1 = User::create (
362
+ '5c8169b1-d6ef-4415-8c39-e1664df8b954 ' ,
363
+ 'Gwénola ' ,
364
+ 'Etheve ' ,
365
+ null
366
+ );
367
+ $ this ->assertTrue ($ user1 ->save ());
368
+ unset($ user1 );
369
+ $ this ->assertNull (
370
+ User::findWhere (
371
+ [
372
+ 'first_name ' => 'Gwénola ' ,
373
+ 'last_name ' => 'Dupond ' ,
374
+ ]
375
+ )
376
+ );
377
+ $ user1 = User::findWhere (
378
+ [
379
+ 'first_name ' => 'Gwénola ' ,
380
+ 'last_name ' => 'Etheve ' ,
381
+ ]
382
+ );
383
+ $ this ->assertTrue ($ user1 ->delete ());
384
+ $ this ->assertFalse ($ user1 ->refresh ());
385
+ $ this ->assertSame (0 , User::count ());
386
+ }
387
+
317
388
public function testUpdateNoChanges (): void
318
389
{
319
390
$ this ->cleanupUsers ();
0 commit comments