diff options
| author | advect <advect@gmail.com> | 2010-07-17 18:46:28 +0900 |
|---|---|---|
| committer | advect <advect@gmail.com> | 2010-07-17 18:46:28 +0900 |
| commit | 78f542f6c0205a7771f273175518db02f461f8e5 (patch) | |
| tree | 8150e3e55e0eeef4ac87a6cb9d691ffd35313a7e /php/tests/013.phpt | |
| parent | a97f9081a3a41180cf1e08f9fd8b41e5b17924eb (diff) | |
| download | msgpack-python-78f542f6c0205a7771f273175518db02f461f8e5.tar.gz | |
Update PHP Extension
Diffstat (limited to 'php/tests/013.phpt')
| -rw-r--r-- | php/tests/013.phpt | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/php/tests/013.phpt b/php/tests/013.phpt new file mode 100644 index 0000000..73f7d33 --- /dev/null +++ b/php/tests/013.phpt @@ -0,0 +1,54 @@ +--TEST-- +Object-Array test +--SKIPIF-- +--FILE-- +<?php +if(!extension_loaded('msgpack')) { + dl('msgpack.' . PHP_SHLIB_SUFFIX); +} + +function test($type, $variable, $test) { + $serialized = msgpack_serialize($variable); + $unserialized = msgpack_unserialize($serialized); + + echo $type, PHP_EOL; + echo bin2hex($serialized), PHP_EOL; + var_dump($unserialized); + echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL; +} + +class Obj { + var $a; + var $b; + + function __construct($a, $b) { + $this->a = $a; + $this->b = $b; + } +} + +$o = array(new Obj(1, 2), new Obj(3, 4)); + + +test('object', $o, false); +?> +--EXPECTF-- +object +820083c0a34f626aa16101a162020183c0a34f626aa16103a16204 +array(2) { + [0]=> + object(Obj)#%d (2) { + ["a"]=> + int(1) + ["b"]=> + int(2) + } + [1]=> + object(Obj)#%d (2) { + ["a"]=> + int(3) + ["b"]=> + int(4) + } +} +OK |
