Skip to content

PHPC-334: Split hex_dump() test case #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/bson/bug0334.phpt → tests/bson/bug0334-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ require_once __DIR__ . "/../utils/basic.inc";
class MyClass implements BSON\Persistable {
function bsonSerialize() {
return array(
"foo" => "bar",
"__pclass" => "baz",
"foo" => "bar",
);
}
function bsonUnserialize(array $data) {
Expand All @@ -25,5 +25,8 @@ $php = toPHP($bson, array('root' => 'array'));
var_dump($php['__pclass']->getData());

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
string(7) "MyClass"
===DONE===
31 changes: 31 additions & 0 deletions tests/bson/bug0334-002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
PHPC-334: Encoded BSON should never have multiple __pclass keys
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"?>
--FILE--
<?php
use MongoDB\BSON as BSON;

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

class MyClass implements BSON\Persistable {
function bsonSerialize() {
return array(
"__pclass" => "baz",
"foo" => "bar",
);
}
function bsonUnserialize(array $data) {
}
}

hex_dump(fromPHP(new MyClass))

?>
===DONE===
<?php exit(0); ?>
--EXPECT--
0 : 28 00 00 00 05 5f 5f 70 63 6c 61 73 73 00 07 00 [(....__pclass...]
10 : 00 00 80 4d 79 43 6c 61 73 73 02 66 6f 6f 00 04 [...MyClass.foo..]
20 : 00 00 00 62 61 72 00 00 [...bar..]
===DONE===