File: bug0592.phpt

package info (click to toggle)
php-mongodb 1.15.0%2B1.11.1%2B1.9.2%2B1.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 63,984 kB
  • sloc: ansic: 328,429; xml: 10,797; php: 4,235; sh: 179; python: 47; pascal: 36; makefile: 3
file content (116 lines) | stat: -rw-r--r-- 2,811 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
--TEST--
PHPC-592: Property name corrupted when unserializing 64-bit integer on 32-bit platform
--SKIPIF--
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?>
--FILE--
<?php

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

$tests = [
    '{ "x": { "$numberLong": "-2147483648" }}',
    '{ "x": { "$numberLong": "2147483647" }}',
    '{ "x": { "$numberLong": "4294967294" }}',
    '{ "x": { "$numberLong": "4294967295" }}',
    '{ "x": { "$numberLong": "9223372036854775807" }}',
    '{ "longFieldName": { "$numberLong": "-2147483648" }}',
    '{ "longFieldName": { "$numberLong": "2147483647" }}',
    '{ "longFieldName": { "$numberLong": "4294967294" }}',
    '{ "longFieldName": { "$numberLong": "4294967295" }}',
    '{ "longFieldName": { "$numberLong": "9223372036854775807" }}',
];

foreach ($tests as $json) {
    printf("Test %s\n", $json);
    try {
        $encoded = toPHP(fromJSON($json));
        var_dump( $encoded );
    } catch ( MongoDB\Driver\Exception\InvalidArgumentException $e ) {
        echo "MongoDB\Driver\Exception\InvalidArgumentException: ", $e->getMessage(), "\n";
    }
    echo "\n";
}

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Test { "x": { "$numberLong": "-2147483648" }}
object(stdClass)#%d (%d) {
  ["x"]=>
  int(-2147483648)
}

Test { "x": { "$numberLong": "2147483647" }}
object(stdClass)#%d (%d) {
  ["x"]=>
  int(2147483647)
}

Test { "x": { "$numberLong": "4294967294" }}
object(stdClass)#%d (%d) {
  ["x"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(10) "4294967294"
  }
}

Test { "x": { "$numberLong": "4294967295" }}
object(stdClass)#%d (%d) {
  ["x"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(10) "4294967295"
  }
}

Test { "x": { "$numberLong": "9223372036854775807" }}
object(stdClass)#%d (%d) {
  ["x"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(19) "9223372036854775807"
  }
}

Test { "longFieldName": { "$numberLong": "-2147483648" }}
object(stdClass)#%d (%d) {
  ["longFieldName"]=>
  int(-2147483648)
}

Test { "longFieldName": { "$numberLong": "2147483647" }}
object(stdClass)#%d (%d) {
  ["longFieldName"]=>
  int(2147483647)
}

Test { "longFieldName": { "$numberLong": "4294967294" }}
object(stdClass)#%d (%d) {
  ["longFieldName"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(10) "4294967294"
  }
}

Test { "longFieldName": { "$numberLong": "4294967295" }}
object(stdClass)#%d (%d) {
  ["longFieldName"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(10) "4294967295"
  }
}

Test { "longFieldName": { "$numberLong": "9223372036854775807" }}
object(stdClass)#%d (%d) {
  ["longFieldName"]=>
  object(MongoDB\BSON\Int64)#%d (%d) {
    ["integer"]=>
    string(19) "9223372036854775807"
  }
}

===DONE===