Skip to content

Commit fa19ed8

Browse files
committed
Merge pull request #67
2 parents 9d7bb9a + 972c5e4 commit fa19ed8

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

tests/bson/bug0334.phpt renamed to tests/bson/bug0334-001.phpt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require_once __DIR__ . "/../utils/basic.inc";
1111
class MyClass implements BSON\Persistable {
1212
function bsonSerialize() {
1313
return array(
14-
"foo" => "bar",
1514
"__pclass" => "baz",
15+
"foo" => "bar",
1616
);
1717
}
1818
function bsonUnserialize(array $data) {
@@ -25,5 +25,8 @@ $php = toPHP($bson, array('root' => 'array'));
2525
var_dump($php['__pclass']->getData());
2626

2727
?>
28+
===DONE===
29+
<?php exit(0); ?>
2830
--EXPECT--
2931
string(7) "MyClass"
32+
===DONE===

tests/bson/bug0334-002.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
PHPC-334: Encoded BSON should never have multiple __pclass keys
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
5+
--FILE--
6+
<?php
7+
use MongoDB\BSON as BSON;
8+
9+
require_once __DIR__ . "/../utils/basic.inc";
10+
11+
class MyClass implements BSON\Persistable {
12+
function bsonSerialize() {
13+
return array(
14+
"__pclass" => "baz",
15+
"foo" => "bar",
16+
);
17+
}
18+
function bsonUnserialize(array $data) {
19+
}
20+
}
21+
22+
hex_dump(fromPHP(new MyClass))
23+
24+
?>
25+
===DONE===
26+
<?php exit(0); ?>
27+
--EXPECT--
28+
0 : 28 00 00 00 05 5f 5f 70 63 6c 61 73 73 00 07 00 [(....__pclass...]
29+
10 : 00 00 80 4d 79 43 6c 61 73 73 02 66 6f 6f 00 04 [...MyClass.foo..]
30+
20 : 00 00 00 62 61 72 00 00 [...bar..]
31+
===DONE===

0 commit comments

Comments
 (0)