@@ -415,16 +415,31 @@ public function testUnset()
415
415
416
416
public function testUpdateSubdocument ()
417
417
{
418
- DB ::collection ('users ' )->insertGetId (array (
419
- 'name ' => 'John Doe ' ,
420
- 'address ' => array ('country ' => 'Belgium ' )
418
+ $ id = DB ::collection ('users ' )->insertGetId (array ('name ' => 'John Doe ' , 'address ' => array ('country ' => 'Belgium ' )));
419
+
420
+ DB ::collection ('users ' )->where ('_id ' , $ id )->update (array ('address.country ' => 'England ' ));
421
+
422
+ $ check = DB ::collection ('users ' )->find ($ id );
423
+ $ this ->assertEquals ('England ' , $ check ['address ' ]['country ' ]);
424
+ }
425
+
426
+ public function testDates ()
427
+ {
428
+ DB ::collection ('users ' )->insert (array (
429
+ array ('name ' => 'John Doe ' , 'birthday ' => new MongoDate (strtotime ("1980-01-01 00:00:00 " ))),
430
+ array ('name ' => 'Jane Doe ' , 'birthday ' => new MongoDate (strtotime ("1981-01-01 00:00:00 " ))),
431
+ array ('name ' => 'Robert Roe ' , 'birthday ' => new MongoDate (strtotime ("1982-01-01 00:00:00 " ))),
432
+ array ('name ' => 'Mark Moe ' , 'birthday ' => new MongoDate (strtotime ("1983-01-01 00:00:00 " ))),
421
433
));
422
434
423
- DB ::collection ('users ' )->where ('name ' , 'John Doe ' )->update (array ('address.country ' => 'England ' ));
435
+ $ user = DB ::collection ('users ' )->where ('birthday ' , new MongoDate (strtotime ("1980-01-01 00:00:00 " )))->first ();
436
+ $ this ->assertEquals ('John Doe ' , $ user ['name ' ]);
424
437
425
- $ check = DB ::collection ('users ' )->where ('name ' , 'John Doe ' )->first ();
438
+ $ start = new MongoDate (strtotime ("1981-01-01 00:00:00 " ));
439
+ $ stop = new MongoDate (strtotime ("1982-01-01 00:00:00 " ));
426
440
427
- $ this ->assertEquals ('England ' , $ check ['address ' ]['country ' ]);
441
+ $ users = DB ::collection ('users ' )->whereBetween ('birthday ' , array ($ start , $ stop ))->get ();
442
+ $ this ->assertEquals (2 , count ($ users ));
428
443
}
429
444
430
445
}
0 commit comments