Skip to content

Commit 7a1b7db

Browse files
committed
Use Int64 instances in tests
1 parent 3a8f90b commit 7a1b7db

22 files changed

+37
-92
lines changed

tests/bson/bson-fromPHP-003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class MyDocument {
1212
}
1313

1414
$tests = array(
15-
array(new MongoDB\BSON\UTCDateTime('1416445411987')),
16-
array('x' => new MongoDB\BSON\UTCDateTime('1416445411987')),
15+
array(new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'))),
16+
array('x' => new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'))),
1717
array(new MyDocument),
1818
array('x' => new MyDocument),
1919
);

tests/bson/bson-fromPHP_error-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $tests = array(
1616
new MongoDB\BSON\ObjectId,
1717
new MongoDB\BSON\Regex('regexp', 'i'),
1818
new MongoDB\BSON\Timestamp(1234, 5678),
19-
new MongoDB\BSON\UTCDateTime('1416445411987'),
19+
new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987')),
2020
);
2121

2222
foreach ($tests as $document) {

tests/bson/bson-toPHP-004.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $tests = [
2929
new MongoDB\BSON\ObjectId('586c18d86118fd6c9012dec1'),
3030
new MongoDB\BSON\Regex('foo'),
3131
new MongoDB\BSON\Timestamp(1234, 5678),
32-
new MongoDB\BSON\UTCDateTime('1483479256924'),
32+
new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1483479256924')),
3333
];
3434

3535
foreach ($tests as $value) {

tests/bson/bson-utcdatetime-001.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require_once __DIR__ . "/../utils/basic.inc";
1111

1212
$manager = create_test_manager();
1313

14-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
14+
$utcdatetime = new MongoDB\BSON\UTCDateTime(2147483647);
1515

1616
$bulk = new MongoDB\Driver\BulkWrite();
1717
$bulk->insert(array('_id' => 1, 'x' => $utcdatetime));
@@ -38,12 +38,12 @@ foreach($tests as $n => $test) {
3838
===DONE===
3939
<?php exit(0); ?>
4040
--EXPECT--
41-
Test#0 { "0" : { "$date" : { "$numberLong" : "1416445411987" } } }
42-
string(59) "{ "0" : { "$date" : { "$numberLong" : "1416445411987" } } }"
43-
string(59) "{ "0" : { "$date" : { "$numberLong" : "1416445411987" } } }"
41+
Test#0 { "0" : { "$date" : { "$numberLong" : "2147483647" } } }
42+
string(56) "{ "0" : { "$date" : { "$numberLong" : "2147483647" } } }"
43+
string(56) "{ "0" : { "$date" : { "$numberLong" : "2147483647" } } }"
4444
bool(true)
45-
Test#1 { "0" : { "$date" : { "$numberLong" : "1416445411987" } } }
46-
string(59) "{ "0" : { "$date" : { "$numberLong" : "1416445411987" } } }"
47-
string(59) "{ "0" : { "$date" : { "$numberLong" : "1416445411987" } } }"
45+
Test#1 { "0" : { "$date" : { "$numberLong" : "2147483647" } } }
46+
string(56) "{ "0" : { "$date" : { "$numberLong" : "2147483647" } } }"
47+
string(56) "{ "0" : { "$date" : { "$numberLong" : "2147483647" } } }"
4848
bool(true)
4949
===DONE===

tests/bson/bson-utcdatetime-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\BSON\UTCDateTime debug handler
33
--FILE--
44
<?php
55

6-
$utcdatetime = new MongoDB\BSON\UTCDateTime('1416445411987');
6+
$utcdatetime = new MongoDB\BSON\UTCDateTime(2147483647);
77

88
var_dump($utcdatetime);
99

@@ -13,6 +13,6 @@ var_dump($utcdatetime);
1313
--EXPECTF--
1414
object(MongoDB\BSON\UTCDateTime)#%d (%d) {
1515
["milliseconds"]=>
16-
%rint\(|string\(13\) "|%r1416445411987%r"|\)%r
16+
%rint\(|string\(10\) "|%r2147483647%r"|\)%r
1717
}
1818
===DONE===

tests/bson/bson-utcdatetime-clone-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MongoDB\BSON\UTCDateTime can be cloned (PHP < 8.2)
88

99
require_once __DIR__ . "/../utils/basic.inc";
1010

11-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
11+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
1212

1313
$clone = clone $utcdatetime;
1414

tests/bson/bson-utcdatetime-clone-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MongoDB\BSON\UTCDateTime can be cloned (PHP >= 8.2)
88

99
require_once __DIR__ . "/../utils/basic.inc";
1010

11-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
11+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
1212

1313
$clone = clone $utcdatetime;
1414

tests/bson/bson-utcdatetime-get_properties-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\BSON\UTCDateTime get_properties handler (get_object_vars)
33
--FILE--
44
<?php
55

6-
$utcdatetime = new MongoDB\BSON\UTCDateTime('1416445411987');
6+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
77

88
var_dump(get_object_vars($utcdatetime));
99

tests/bson/bson-utcdatetime-get_properties-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\BSON\UTCDateTime get_properties handler (foreach)
33
--FILE--
44
<?php
55

6-
$utcdatetime = new MongoDB\BSON\UTCDateTime('1416445411987');
6+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
77

88
foreach ($utcdatetime as $key => $value) {
99
var_dump($key);

tests/bson/bson-utcdatetime-int-size-001.phpt

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/bson/bson-utcdatetime-int-size-002.phpt

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/bson/bson-utcdatetime-serialization-003.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ MongoDB\BSON\UTCDateTime serialization (__serialize and __unserialize)
44
<?php
55

66
$tests = [
7-
'0',
8-
'-1416445411987',
9-
'1416445411987',
7+
0,
8+
new MongoDB\BSON\Int64('-1416445411987'),
9+
new MongoDB\BSON\Int64('1416445411987'),
1010
];
1111

1212
foreach ($tests as $milliseconds) {

tests/bson/bson-utcdatetime-todatetime-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date.timezone=America/Los_Angeles
55
--FILE--
66
<?php
77

8-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
8+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
99
$datetime = $utcdatetime->toDateTime();
1010
var_dump(get_class($datetime));
1111
var_dump($datetime->format(DATE_RSS));

tests/bson/bson-utcdatetime-todatetime-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date.timezone=UTC
55
--FILE--
66
<?php
77

8-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
8+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
99
$datetime = $utcdatetime->toDateTime();
1010
var_dump(get_class($datetime));
1111
echo $datetime->format('U.u'), "\n";

tests/bson/bson-utcdatetime-todatetimeimmutable-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date.timezone=America/Los_Angeles
55
--FILE--
66
<?php
77

8-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
8+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
99
$datetime = $utcdatetime->toDateTimeImmutable();
1010
var_dump(get_class($datetime));
1111
var_dump($datetime->format(DATE_RSS));

tests/bson/bson-utcdatetime-todatetimeimmutable-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date.timezone=UTC
55
--FILE--
66
<?php
77

8-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
8+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
99
$datetime = $utcdatetime->toDateTimeImmutable();
1010
var_dump(get_class($datetime));
1111
echo $datetime->format('U.u'), "\n";

tests/bson/bson-utcdatetime-tostring-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\BSON\UTCDateTime::__toString()
33
--FILE--
44
<?php
55

6-
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
6+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
77
var_dump((string) $utcdatetime);
88

99
?>

tests/bson/bson-utcdatetime_error-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ echo throws(function() {
1414
<?php exit(0); ?>
1515
--EXPECT--
1616
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
17-
Expected instance of DateTimeInterface, stdClass given
17+
Expected instance of DateTimeInterface or MongoDB\BSON\Int64, stdClass given
1818
===DONE===

tests/bson/bson-utcdatetime_error-003.phpt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@ echo throws(function() {
2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
29-
--EXPECT--
29+
--EXPECTF--
30+
Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a string is deprecated and be removed in ext-mongodb 2.0 in %S
3031
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3132
Error parsing "1234.5678" as 64-bit integer for MongoDB\BSON\UTCDateTime initialization
33+
34+
Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a string is deprecated and be removed in ext-mongodb 2.0 in %S
3235
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3336
Error parsing "9223372036854775808" as 64-bit integer for MongoDB\BSON\UTCDateTime initialization
37+
38+
Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a string is deprecated and be removed in ext-mongodb 2.0 in %S
3439
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3540
Error parsing "-9223372036854775809" as 64-bit integer for MongoDB\BSON\UTCDateTime initialization
41+
42+
Deprecated: MongoDB\BSON\UTCDateTime::__construct(): Creating a MongoDB\BSON\UTCDateTime instance with a string is deprecated and be removed in ext-mongodb 2.0 in %S
3643
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3744
Error parsing "18446744073709551615" as 64-bit integer for MongoDB\BSON\UTCDateTime initialization
3845
===DONE===

tests/bson/bson-utcdatetimeinterface-001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ MongoDB\BSON\UTCDateTimeInterface is implemented by MongoDB\BSON\UTCDateTime
33
--FILE--
44
<?php
55

6-
$date = new MongoDB\BSON\UTCDateTime('1416445411987');
6+
$date = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1416445411987'));
77
var_dump($date instanceof MongoDB\BSON\UTCDateTimeInterface);
88

99
?>

tests/bson/bug0631.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ date.timezone=UTC
77

88
require_once __DIR__ . '/../utils/basic.inc';
99

10-
$utcdatetime = new MongoDB\BSON\UTCDateTime('1466540755123');
10+
$utcdatetime = new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1466540755123'));
1111
$datetime = $utcdatetime->toDateTime();
1212
$s = serialize($datetime);
1313

tests/writeResult/writeresult-getupsertedids-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $tests = [
2525
new MongoDB\BSON\MinKey,
2626
new MongoDB\BSON\ObjectId('586c18d86118fd6c9012dec1'),
2727
new MongoDB\BSON\Timestamp(1234, 5678),
28-
new MongoDB\BSON\UTCDateTime('1483479256924'),
28+
new MongoDB\BSON\UTCDateTime(new MongoDB\BSON\Int64('1483479256924')),
2929
];
3030

3131
$manager = create_test_manager();

0 commit comments

Comments
 (0)