~ufirst/phpredis/igbinary

« back to all changes in this revision

Viewing changes to igbinary-1.2.1/tests/igbinary_033.phpt

  • Committer: Michael Ruoss
  • Date: 2015-03-18 14:12:19 UTC
  • Revision ID: git-v1:c591bdc61de714458440ff13454bc51d94ab5f3d
new build info structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Object test, cyclic references
 
3
--SKIPIF--
 
4
<?php
 
5
if(!extension_loaded('igbinary')) {
 
6
        echo "skip no igbinary";
 
7
}
 
8
--FILE--
 
9
<?php 
 
10
 
 
11
class Foo {
 
12
        public $parent;
 
13
        public $children;
 
14
 
 
15
        public function __construct() {
 
16
                $this->parent = null;
 
17
                $this->children = array();
 
18
        }
 
19
 
 
20
        public function addChild(Foo $obj) {
 
21
                $this->children[] = $obj;
 
22
                $obj->setParent($this);
 
23
        }
 
24
 
 
25
        public function setParent(Foo $obj) {
 
26
                $this->parent = $obj;
 
27
        }
 
28
}
 
29
 
 
30
$obj1 = new Foo();
 
31
 
 
32
for ($i = 0; $i < 10; $i++) {
 
33
        $obj = new Foo();
 
34
        $obj1->addChild($obj);
 
35
}
 
36
 
 
37
$o = igbinary_unserialize(igbinary_serialize($obj1->children));
 
38
 
 
39
foreach ($obj1->children as $k => $v) {
 
40
        $obj_v = $v;
 
41
        $o_v = $o[$k];
 
42
 
 
43
        echo gettype($obj_v), "\t", gettype($o_v), "\n";
 
44
}
 
45
--EXPECT--
 
46
object  object
 
47
object  object
 
48
object  object
 
49
object  object
 
50
object  object
 
51
object  object
 
52
object  object
 
53
object  object
 
54
object  object
 
55
object  object