1--TEST--
2Object test, __sleep error cases
3--SKIPIF--
4--FILE--
5<?php
6if(!extension_loaded('msgpack')) {
7    dl('msgpack.' . PHP_SHLIB_SUFFIX);
8}
9
10function test($type, $variable, $test) {
11    $serialized = msgpack_serialize($variable);
12    $unserialized = msgpack_unserialize($serialized);
13
14    echo $type, PHP_EOL;
15    echo bin2hex($serialized), PHP_EOL;
16    var_dump($unserialized);
17    echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
18}
19
20class Obj {
21    var $a;
22    var $b;
23
24    function __construct($a, $b) {
25        $this->a = $a;
26        $this->b = $b;
27    }
28
29    function __sleep() {
30        return array('c');
31    }
32
33#   function __wakeup() {
34#       $this->b = $this->a * 3;
35#   }
36}
37
38class Opj {
39    var $a;
40    var $b;
41
42    function __construct($a, $b) {
43        $this->a = $a;
44        $this->b = $b;
45    }
46
47    function __sleep() {
48        return array(1);
49    }
50
51#   function __wakeup() {
52#
53#   }
54}
55
56$o = new Obj(1, 2);
57$p = new Opj(1, 2);
58
59test('nonexisting', $o, true);
60test('wrong', $p, true);
61?>
62--EXPECTF--
63Notice: [msgpack] (msgpack_serialize_class) "c" returned as member variable from __sleep() but does not exist in %s on line %d
64nonexisting
6582c0a34f626aa163c0
66object(Obj)#%d (3) {
67  ["a"]=>
68  NULL
69  ["b"]=>
70  NULL
71  ["c"]=>
72  NULL
73}
74OK
75
76Notice: [msgpack] (msgpack_serialize_class) __sleep should return an array only containing the names of instance-variables to serialize in %s018.php on line %d
77
78Warning: [msgpack] (php_msgpack_unserialize) Insufficient data for unserializing in %s018.php on line %d
79wrong
8082c0a34f706a
81bool(false)
82OK
83