|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +use MongoDB\BSON\UTCDateTime; |
| 4 | +use MongoDB\BSON\Regex; |
| 5 | + |
3 | 6 | class QueryBuilderTest extends TestCase { |
4 | 7 |
|
5 | 8 | public function tearDown() |
@@ -241,7 +244,7 @@ public function testPush() |
241 | 244 | $this->assertEquals(4, count($user['tags'])); |
242 | 245 | $this->assertEquals(2, count($user['messages'])); |
243 | 246 |
|
244 | | - DB::collection('users')->where('_id', $id)->push(['messages' => ['date' => new MongoDate(), 'body' => 'Hi John']]); |
| 247 | + DB::collection('users')->where('_id', $id)->push(['messages' => ['date' => new DateTime(), 'body' => 'Hi John']]); |
245 | 248 | $user = DB::collection('users')->find($id); |
246 | 249 | $this->assertEquals(3, count($user['messages'])); |
247 | 250 | } |
@@ -461,20 +464,20 @@ public function testUpdateSubdocument() |
461 | 464 | public function testDates() |
462 | 465 | { |
463 | 466 | DB::collection('users')->insert([ |
464 | | - ['name' => 'John Doe', 'birthday' => new MongoDate(strtotime("1980-01-01 00:00:00"))], |
465 | | - ['name' => 'Jane Doe', 'birthday' => new MongoDate(strtotime("1981-01-01 00:00:00"))], |
466 | | - ['name' => 'Robert Roe', 'birthday' => new MongoDate(strtotime("1982-01-01 00:00:00"))], |
467 | | - ['name' => 'Mark Moe', 'birthday' => new MongoDate(strtotime("1983-01-01 00:00:00"))], |
| 467 | + ['name' => 'John Doe', 'birthday' => new UTCDateTime(1000 * strtotime("1980-01-01 00:00:00"))], |
| 468 | + ['name' => 'Jane Doe', 'birthday' => new UTCDateTime(1000 * strtotime("1981-01-01 00:00:00"))], |
| 469 | + ['name' => 'Robert Roe', 'birthday' => new UTCDateTime(1000 * strtotime("1982-01-01 00:00:00"))], |
| 470 | + ['name' => 'Mark Moe', 'birthday' => new UTCDateTime(1000 * strtotime("1983-01-01 00:00:00"))], |
468 | 471 | ]); |
469 | 472 |
|
470 | | - $user = DB::collection('users')->where('birthday', new MongoDate(strtotime("1980-01-01 00:00:00")))->first(); |
| 473 | + $user = DB::collection('users')->where('birthday', new UTCDateTime(1000 * strtotime("1980-01-01 00:00:00")))->first(); |
471 | 474 | $this->assertEquals('John Doe', $user['name']); |
472 | 475 |
|
473 | 476 | $user = DB::collection('users')->where('birthday', '=', new DateTime("1980-01-01 00:00:00"))->first(); |
474 | 477 | $this->assertEquals('John Doe', $user['name']); |
475 | 478 |
|
476 | | - $start = new MongoDate(strtotime("1981-01-01 00:00:00")); |
477 | | - $stop = new MongoDate(strtotime("1982-01-01 00:00:00")); |
| 479 | + $start = new UTCDateTime(1000 * strtotime("1981-01-01 00:00:00")); |
| 480 | + $stop = new UTCDateTime(1000 * strtotime("1982-01-01 00:00:00")); |
478 | 481 |
|
479 | 482 | $users = DB::collection('users')->whereBetween('birthday', [$start, $stop])->get(); |
480 | 483 | $this->assertEquals(2, count($users)); |
@@ -537,11 +540,11 @@ public function testOperators() |
537 | 540 | $results = DB::collection('items')->where('tags', 'size', 4)->get(); |
538 | 541 | $this->assertEquals(1, count($results)); |
539 | 542 |
|
540 | | - $regex = new MongoRegex("/.*doe/i"); |
| 543 | + $regex = new Regex("/.*doe/i"); |
541 | 544 | $results = DB::collection('users')->where('name', 'regex', $regex)->get(); |
542 | 545 | $this->assertEquals(2, count($results)); |
543 | 546 |
|
544 | | - $regex = new MongoRegex("/.*doe/i"); |
| 547 | + $regex = new Regex("/.*doe/i"); |
545 | 548 | $results = DB::collection('users')->where('name', 'regexp', $regex)->get(); |
546 | 549 | $this->assertEquals(2, count($results)); |
547 | 550 |
|
|
0 commit comments