New PHP5 APC - version 3.0.18, using PHP5 5.2.0-8+etch10,
[php5-apc.git] / tests / apc_003.phpt
1 --TEST--
2 APC: apc_store/fetch with objects
3 --SKIPIF--
4 <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5 --INI--
6 apc.enabled=1
7 apc.enable_cli=1
8 apc.file_update_protection=0
9 --FILE--
10 <?php
11
12 class foo { }
13 $foo = new foo;
14 var_dump($foo);
15 apc_store('foo',$foo);
16 unset($foo);
17 $bar = apc_fetch('foo');
18 var_dump($bar);
19 $bar->a = true;
20 var_dump($bar);
21
22 class bar extends foo
23 {
24         public    $pub = 'bar';
25         protected $pro = 'bar';
26         private   $pri = 'bar'; // we don't see this, we'd need php 5.1 new serialization
27         
28         function __construct()
29         {
30                 $this->bar = true;
31         }
32         
33         function change()
34         {
35                 $this->pri = 'mod';
36         }
37 }
38
39 class baz extends bar
40 {
41         private $pri = 'baz';
42
43         function __construct()
44         {
45                 parent::__construct();
46                 $this->baz = true;
47         }
48 }
49
50 $baz = new baz;
51 var_dump($baz);
52 $baz->change();
53 var_dump($baz);
54 apc_store('baz', $baz);
55 unset($baz);
56 var_dump(apc_fetch('baz'));
57
58 ?>
59 ===DONE===
60 <?php exit(0); ?>
61 --EXPECTF--
62 object(foo)#%d (0) {
63 }
64 object(foo)#%d (0) {
65 }
66 object(foo)#%d (1) {
67   ["a"]=>
68   bool(true)
69 }
70 object(baz)#%d (6) {
71   ["pri:private"]=>
72   string(3) "baz"
73   ["pub"]=>
74   string(3) "bar"
75   ["pro:protected"]=>
76   string(3) "bar"
77   ["pri:private"]=>
78   string(3) "bar"
79   ["bar"]=>
80   bool(true)
81   ["baz"]=>
82   bool(true)
83 }
84 object(baz)#%d (6) {
85   ["pri:private"]=>
86   string(3) "baz"
87   ["pub"]=>
88   string(3) "bar"
89   ["pro:protected"]=>
90   string(3) "bar"
91   ["pri:private"]=>
92   string(3) "mod"
93   ["bar"]=>
94   bool(true)
95   ["baz"]=>
96   bool(true)
97 }
98 object(baz)#%d (6) {
99   ["pri:private"]=>
100   string(3) "baz"
101   ["pub"]=>
102   string(3) "bar"
103   ["pro:protected"]=>
104   string(3) "bar"
105   ["pri:private"]=>
106   string(3) "mod"
107   ["bar"]=>
108   bool(true)
109   ["baz"]=>
110   bool(true)
111 }
112 ===DONE===