@@ -415,16 +415,31 @@ public function testUnset()
415415
416416 public function testUpdateSubdocument ()
417417 {
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 " ))),
421433 ));
422434
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 ' ]);
424437
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 " ));
426440
427- $ this ->assertEquals ('England ' , $ check ['address ' ]['country ' ]);
441+ $ users = DB ::collection ('users ' )->whereBetween ('birthday ' , array ($ start , $ stop ))->get ();
442+ $ this ->assertEquals (2 , count ($ users ));
428443 }
429444
430445}
0 commit comments