Skip to content

Commit 19034f9

Browse files
committed
Split out UTCDateTime toDateTime and toString tests
This also removes an unrelated test where DateTime was being encoded as a BSON document and printed as JSON, which happened to fail on HHVM since its DateTime object does not have the undocumented class properties found in PHP.
1 parent 319d748 commit 19034f9

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

tests/bson/bson-utcdatetime-001.phpt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ $query = new MongoDB\Driver\Query(array('_id' => 1));
1919
$cursor = $manager->executeQuery(NS, $query);
2020
$results = iterator_to_array($cursor);
2121

22-
$datetime = $utcdatetime->toDateTime();
23-
var_dump($datetime->format(DATE_RSS));
24-
var_dump((string) $utcdatetime);
25-
2622
$tests = array(
2723
array($utcdatetime),
2824
array($results[0]->x),
29-
array($datetime),
3025
);
3126

3227
foreach($tests as $n => $test) {
@@ -40,9 +35,7 @@ foreach($tests as $n => $test) {
4035
?>
4136
===DONE===
4237
<?php exit(0); ?>
43-
--EXPECTF--
44-
string(31) "Thu, 20 Nov 2014 01:03:31 +0000"
45-
string(13) "1416445411987"
38+
--EXPECT--
4639
Test#0 { "0" : { "$date" : 1416445411987 } }
4740
string(37) "{ "0" : { "$date" : 1416445411987 } }"
4841
string(37) "{ "0" : { "$date" : 1416445411987 } }"
@@ -51,8 +44,4 @@ Test#1 { "0" : { "$date" : 1416445411987 } }
5144
string(37) "{ "0" : { "$date" : 1416445411987 } }"
5245
string(37) "{ "0" : { "$date" : 1416445411987 } }"
5346
bool(true)
54-
Test#2 { "0" : { "date" : "2014-11-20 01:03:31.987%r(0+)%r", "timezone_type" : 1, "timezone" : "+00:00" } }
55-
string(98) "{ "0" : { "date" : "2014-11-20 01:03:31.987%r(0+)%r", "timezone_type" : 1, "timezone" : "+00:00" } }"
56-
string(98) "{ "0" : { "date" : "2014-11-20 01:03:31.987%r(0+)%r", "timezone_type" : 1, "timezone" : "+00:00" } }"
57-
bool(false)
5847
===DONE===
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
BSON BSON\UTCDateTime::toDateTime()
3+
--INI--
4+
date.timezone=America/Los_Angeles
5+
--SKIPIF--
6+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
7+
--FILE--
8+
<?php
9+
use MongoDB\BSON as BSON;
10+
11+
require_once __DIR__ . "/../utils/basic.inc";
12+
13+
$utcdatetime = new BSON\UTCDateTime("1416445411987");
14+
$datetime = $utcdatetime->toDateTime();
15+
var_dump($datetime->format(DATE_RSS));
16+
17+
?>
18+
===DONE===
19+
<?php exit(0); ?>
20+
--EXPECTF--
21+
string(31) "Thu, 20 Nov 2014 01:03:31 +0000"
22+
===DONE===
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
BSON BSON\UTCDateTime::__toString()
3+
--INI--
4+
date.timezone=America/Los_Angeles
5+
--SKIPIF--
6+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
7+
--FILE--
8+
<?php
9+
use MongoDB\BSON as BSON;
10+
11+
require_once __DIR__ . "/../utils/basic.inc";
12+
13+
$utcdatetime = new BSON\UTCDateTime("1416445411987");
14+
var_dump((string) $utcdatetime);
15+
16+
?>
17+
===DONE===
18+
<?php exit(0); ?>
19+
--EXPECTF--
20+
string(13) "1416445411987"
21+
===DONE===

0 commit comments

Comments
 (0)