11--TEST--
2- MongoDB\BSON\toPHP(): BSON decoding throws multiple exceptions
2+ MongoDB\BSON\toPHP(): BSON decoding shows multiple warnings
33--FILE--
44<?php
55
6- require_once __DIR__ . '/../utils/tools.php ' ;
7-
86$ tests = [
97 // two undefined fields in root document
108 pack ('VCa*xCa*xx ' , 13 , 0x06 , 'u1 ' , 0x06 , 'u2 ' ),
@@ -18,45 +16,45 @@ $tests = [
1816 pack ('VCa*xVCa*xxCa*xVCa*xxx ' , 31 , 0x03 , 'e1 ' , 9 , 0x06 , 'u1 ' , 0x03 , 'e2 ' , 9 , 0x06 , 'u2 ' ),
1917];
2018
19+ ini_set ('mongodb.debug ' , 'stdout ' );
2120foreach ($ tests as $ bson ) {
22- try {
23- var_dump (toPHP ($ bson ));
24- } catch (MongoDB \Driver \Exception \UnexpectedValueException $ e ) {
25- do {
26- printf ("OK: %s \n%s \n" , get_class ($ e ), $ e ->getMessage ());
27- } while ($ e = $ e ->getPrevious ());
28- }
29-
30- echo "\n" ;
21+ var_dump (MongoDB \BSON \toPHP ($ bson ));
3122}
32-
23+ ini_set ( ' mongodb.debug ' , ' off ' );
3324?>
3425===DONE===
3526<?php exit (0 ); ?>
36- --EXPECT--
37- OK: MongoDB\Driver\Exception\UnexpectedValueException
38- Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
39- OK: MongoDB\Driver\Exception\UnexpectedValueException
40- Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
41-
42- OK: MongoDB\Driver\Exception\UnexpectedValueException
43- Detected unsupported BSON type 0x0E (symbol) for fieldname "s1"
44- OK: MongoDB\Driver\Exception\UnexpectedValueException
45- Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
46-
47- OK: MongoDB\Driver\Exception\UnexpectedValueException
48- Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
49- OK: MongoDB\Driver\Exception\UnexpectedValueException
50- Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
51-
52- OK: MongoDB\Driver\Exception\UnexpectedValueException
53- Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
54- OK: MongoDB\Driver\Exception\UnexpectedValueException
55- Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
56-
57- OK: MongoDB\Driver\Exception\UnexpectedValueException
58- Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
59- OK: MongoDB\Driver\Exception\UnexpectedValueException
60- Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
61-
27+ --EXPECTF--
28+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
29+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
30+ object(stdClass)#%d (%d) {
31+ }
32+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
33+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x0E (symbol) for fieldname "s1"
34+ object(stdClass)#%d (%d) {
35+ }
36+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
37+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
38+ object(stdClass)#%d (%d) {
39+ ["e1"]=>
40+ object(stdClass)#%d (0) {
41+ }
42+ }
43+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
44+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
45+ object(stdClass)#%d (%d) {
46+ ["e1"]=>
47+ object(stdClass)#%d (0) {
48+ }
49+ }
50+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u1"
51+ [%s] PHONGO-BSON: WARNING > Detected unsupported BSON type 0x06 (undefined) for fieldname "u2"
52+ object(stdClass)#%d (%d) {
53+ ["e1"]=>
54+ object(stdClass)#%d (0) {
55+ }
56+ ["e2"]=>
57+ object(stdClass)#%d (0) {
58+ }
59+ }
6260===DONE===
0 commit comments