Skip to content

Commit 7000993

Browse files
authored
Fix failing tests on x86 systems (#1609)
1 parent e40362f commit 7000993

File tree

3 files changed

+122
-14
lines changed

3 files changed

+122
-14
lines changed

tests/bson/bson-int64-001.phpt

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ $tests = [
1717
];
1818

1919
foreach($tests as $test) {
20-
$bson = fromPHP($test);
21-
$testRoundtripped = toPHP($bson);
22-
$bsonRoundtripped = fromPHP($testRoundtripped);
20+
$bson = MongoDB\BSON\fromPHP($test);
21+
$testRoundtripped = MongoDB\BSON\toPHP($bson);
22+
$bsonRoundtripped = MongoDB\BSON\fromPHP($testRoundtripped);
23+
$json = MongoDB\BSON\toJSON($bson);
24+
$jsonRoundtripped = MongoDB\BSON\toJSON($bsonRoundtripped);
2325

2426
var_dump($test->int64 instanceof MongoDB\BSON\Int64);
2527
var_dump($testRoundtripped->int64 instanceof MongoDB\BSON\Int64);
26-
var_dump(toJSON($bson), toJSON($bsonRoundtripped));
28+
var_dump($json, $jsonRoundtripped);
2729
var_dump($test == $testRoundtripped);
2830

2931
echo "\n";
@@ -32,25 +34,64 @@ foreach($tests as $test) {
3234
?>
3335
===DONE===
3436
<?php exit(0); ?>
35-
--EXPECT--
37+
--EXPECTF--
38+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
39+
40+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
41+
42+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
43+
44+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
45+
46+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
3647
bool(true)
3748
bool(true)
3849
string(33) "{ "int64" : 9223372036854775807 }"
3950
string(33) "{ "int64" : 9223372036854775807 }"
4051
bool(true)
4152

53+
54+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
55+
56+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
57+
58+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
59+
60+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
61+
62+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
4263
bool(true)
4364
bool(true)
4465
string(34) "{ "int64" : -9223372036854775808 }"
4566
string(34) "{ "int64" : -9223372036854775808 }"
4667
bool(true)
4768

69+
70+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
71+
72+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
73+
74+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
75+
76+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
77+
78+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
4879
bool(true)
4980
bool(true)
5081
string(24) "{ "int64" : 2147483648 }"
5182
string(24) "{ "int64" : 2147483648 }"
5283
bool(true)
5384

85+
86+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
87+
88+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
89+
90+
Deprecated: Function MongoDB\BSON\fromPHP() is deprecated in %s
91+
92+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
93+
94+
Deprecated: Function MongoDB\BSON\toJSON() is deprecated in %s
5495
bool(true)
5596
bool(true)
5697
string(25) "{ "int64" : -2147483649 }"

tests/bson/bson-int64-002.phpt

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,88 @@ MongoDB\BSON\Int64 wraps 64-bit integers on 32-bit platforms
88
require_once __DIR__ . '/../utils/basic.inc';
99

1010
$tests = [
11-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"max64": {"$numberLong": "9223372036854775807"}}')),
12-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"min64": {"$numberLong": "-9223372036854775808"}}')),
13-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"max32+1": {"$numberLong": "2147483648"}}')),
14-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"min32-1": {"$numberLong": "-2147483649"}}')),
11+
'{"max64": {"$numberLong": "9223372036854775807"}}',
12+
'{"min64": {"$numberLong": "-9223372036854775808"}}',
13+
'{"max32+1": {"$numberLong": "2147483648"}}',
14+
'{"min32-1": {"$numberLong": "-2147483649"}}',
1515
// Numbers within the range of 32-bit integers will not be wrapped
16-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"max32": {"$numberLong": "2147483647"}}')),
17-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"min32": {"$numberLong": "-2147483648"}}')),
18-
MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{"zero": {"$numberLong": "0"}}')),
16+
'{"max32": {"$numberLong": "2147483647"}}',
17+
'{"min32": {"$numberLong": "-2147483648"}}',
18+
'{"zero": {"$numberLong": "0"}}',
1919

2020
];
2121

2222
foreach ($tests as $test) {
23-
var_dump($test);
23+
var_dump(MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON($test)));
2424
}
2525

2626
?>
2727
===DONE===
2828
<?php exit(0); ?>
2929
--EXPECTF--
30+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
31+
32+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
3033
object(stdClass)#%d (%d) {
3134
["max64"]=>
3235
object(MongoDB\BSON\Int64)#%d (%d) {
3336
["integer"]=>
3437
string(19) "9223372036854775807"
3538
}
3639
}
40+
41+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
42+
43+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
3744
object(stdClass)#%d (%d) {
3845
["min64"]=>
3946
object(MongoDB\BSON\Int64)#%d (%d) {
4047
["integer"]=>
4148
string(20) "-9223372036854775808"
4249
}
4350
}
51+
52+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
53+
54+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
4455
object(stdClass)#%d (%d) {
4556
["max32+1"]=>
4657
object(MongoDB\BSON\Int64)#%d (%d) {
4758
["integer"]=>
4859
string(10) "2147483648"
4960
}
5061
}
62+
63+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
64+
65+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
5166
object(stdClass)#%d (%d) {
5267
["min32-1"]=>
5368
object(MongoDB\BSON\Int64)#%d (%d) {
5469
["integer"]=>
5570
string(11) "-2147483649"
5671
}
5772
}
73+
74+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
75+
76+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
5877
object(stdClass)#%d (%d) {
5978
["max32"]=>
6079
int(2147483647)
6180
}
81+
82+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
83+
84+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
6285
object(stdClass)#%d (%d) {
6386
["min32"]=>
6487
int(-2147483648)
6588
}
89+
90+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
91+
92+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
6693
object(stdClass)#%d (%d) {
6794
["zero"]=>
6895
int(0)

tests/bson/bug0592.phpt

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $tests = [
2323
foreach ($tests as $json) {
2424
printf("Test %s\n", $json);
2525
try {
26-
$encoded = toPHP(fromJSON($json));
26+
$encoded = MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON($json));
2727
var_dump( $encoded );
2828
} catch ( MongoDB\Driver\Exception\InvalidArgumentException $e ) {
2929
echo "MongoDB\Driver\Exception\InvalidArgumentException: ", $e->getMessage(), "\n";
@@ -36,18 +36,30 @@ foreach ($tests as $json) {
3636
<?php exit(0); ?>
3737
--EXPECTF--
3838
Test { "x": { "$numberLong": "-2147483648" }}
39+
40+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
41+
42+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
3943
object(stdClass)#%d (%d) {
4044
["x"]=>
4145
int(-2147483648)
4246
}
4347

4448
Test { "x": { "$numberLong": "2147483647" }}
49+
50+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
51+
52+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
4553
object(stdClass)#%d (%d) {
4654
["x"]=>
4755
int(2147483647)
4856
}
4957

5058
Test { "x": { "$numberLong": "4294967294" }}
59+
60+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
61+
62+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
5163
object(stdClass)#%d (%d) {
5264
["x"]=>
5365
object(MongoDB\BSON\Int64)#%d (%d) {
@@ -57,6 +69,10 @@ object(stdClass)#%d (%d) {
5769
}
5870

5971
Test { "x": { "$numberLong": "4294967295" }}
72+
73+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
74+
75+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
6076
object(stdClass)#%d (%d) {
6177
["x"]=>
6278
object(MongoDB\BSON\Int64)#%d (%d) {
@@ -66,6 +82,10 @@ object(stdClass)#%d (%d) {
6682
}
6783

6884
Test { "x": { "$numberLong": "9223372036854775807" }}
85+
86+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
87+
88+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
6989
object(stdClass)#%d (%d) {
7090
["x"]=>
7191
object(MongoDB\BSON\Int64)#%d (%d) {
@@ -75,18 +95,30 @@ object(stdClass)#%d (%d) {
7595
}
7696

7797
Test { "longFieldName": { "$numberLong": "-2147483648" }}
98+
99+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
100+
101+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
78102
object(stdClass)#%d (%d) {
79103
["longFieldName"]=>
80104
int(-2147483648)
81105
}
82106

83107
Test { "longFieldName": { "$numberLong": "2147483647" }}
108+
109+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
110+
111+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
84112
object(stdClass)#%d (%d) {
85113
["longFieldName"]=>
86114
int(2147483647)
87115
}
88116

89117
Test { "longFieldName": { "$numberLong": "4294967294" }}
118+
119+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
120+
121+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
90122
object(stdClass)#%d (%d) {
91123
["longFieldName"]=>
92124
object(MongoDB\BSON\Int64)#%d (%d) {
@@ -96,6 +128,10 @@ object(stdClass)#%d (%d) {
96128
}
97129

98130
Test { "longFieldName": { "$numberLong": "4294967295" }}
131+
132+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
133+
134+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
99135
object(stdClass)#%d (%d) {
100136
["longFieldName"]=>
101137
object(MongoDB\BSON\Int64)#%d (%d) {
@@ -105,6 +141,10 @@ object(stdClass)#%d (%d) {
105141
}
106142

107143
Test { "longFieldName": { "$numberLong": "9223372036854775807" }}
144+
145+
Deprecated: Function MongoDB\BSON\fromJSON() is deprecated in %s
146+
147+
Deprecated: Function MongoDB\BSON\toPHP() is deprecated in %s
108148
object(stdClass)#%d (%d) {
109149
["longFieldName"]=>
110150
object(MongoDB\BSON\Int64)#%d (%d) {

0 commit comments

Comments
 (0)