Skip to content

Commit 1b32d02

Browse files
committed
Fix some classes in tests
1 parent b2f33fe commit 1b32d02

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="true"
10+
stopOnFailure="false"
1111
syntaxCheck="false"
1212
>
1313
<testsuites>

tests/QueryBuilderTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use MongoDB\BSON\UTCDateTime;
4+
use MongoDB\BSON\Regex;
5+
36
class QueryBuilderTest extends TestCase {
47

58
public function tearDown()
@@ -241,7 +244,7 @@ public function testPush()
241244
$this->assertEquals(4, count($user['tags']));
242245
$this->assertEquals(2, count($user['messages']));
243246

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']]);
245248
$user = DB::collection('users')->find($id);
246249
$this->assertEquals(3, count($user['messages']));
247250
}
@@ -461,20 +464,20 @@ public function testUpdateSubdocument()
461464
public function testDates()
462465
{
463466
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"))],
468471
]);
469472

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();
471474
$this->assertEquals('John Doe', $user['name']);
472475

473476
$user = DB::collection('users')->where('birthday', '=', new DateTime("1980-01-01 00:00:00"))->first();
474477
$this->assertEquals('John Doe', $user['name']);
475478

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"));
478481

479482
$users = DB::collection('users')->whereBetween('birthday', [$start, $stop])->get();
480483
$this->assertEquals(2, count($users));
@@ -537,11 +540,11 @@ public function testOperators()
537540
$results = DB::collection('items')->where('tags', 'size', 4)->get();
538541
$this->assertEquals(1, count($results));
539542

540-
$regex = new MongoRegex("/.*doe/i");
543+
$regex = new Regex("/.*doe/i");
541544
$results = DB::collection('users')->where('name', 'regex', $regex)->get();
542545
$this->assertEquals(2, count($results));
543546

544-
$regex = new MongoRegex("/.*doe/i");
547+
$regex = new Regex("/.*doe/i");
545548
$results = DB::collection('users')->where('name', 'regexp', $regex)->get();
546549
$this->assertEquals(2, count($results));
547550

0 commit comments

Comments
 (0)