Annotation of embedaddon/php/ext/spl/tests/spl_autoload_007.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: SPL: spl_autoload() with inaccessible methods
3: --INI--
4: include_path=.
5: --FILE--
6: <?php
7:
8: class MyAutoLoader {
9:
10: static protected function noAccess($className) {
11: echo __METHOD__ . "($className)\n";
12: }
13:
14: static function autoLoad($className) {
15: echo __METHOD__ . "($className)\n";
16: }
17:
18: function dynaLoad($className) {
19: echo __METHOD__ . "($className)\n";
20: }
21: }
22:
23: $obj = new MyAutoLoader;
24:
25: $funcs = array(
26: 'MyAutoLoader::notExist',
27: 'MyAutoLoader::noAccess',
28: 'MyAutoLoader::autoLoad',
29: 'MyAutoLoader::dynaLoad',
30: array('MyAutoLoader', 'notExist'),
31: array('MyAutoLoader', 'noAccess'),
32: array('MyAutoLoader', 'autoLoad'),
33: array('MyAutoLoader', 'dynaLoad'),
34: array($obj, 'notExist'),
35: array($obj, 'noAccess'),
36: array($obj, 'autoLoad'),
37: array($obj, 'dynaLoad'),
38: );
39:
40: foreach($funcs as $idx => $func)
41: {
42: if ($idx) echo "\n";
43: try
44: {
45: var_dump($func);
46: spl_autoload_register($func);
47: echo "ok\n";
48: }
49: catch (Exception $e)
50: {
51: echo $e->getMessage() . "\n";
52: }
53: }
54:
55: ?>
56: ===DONE===
57: <?php exit(0); ?>
58: --EXPECTF--
59: string(22) "MyAutoLoader::notExist"
60: Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notExist')
61:
62: string(22) "MyAutoLoader::noAccess"
63: Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
64:
65: string(22) "MyAutoLoader::autoLoad"
66: ok
67:
68: string(22) "MyAutoLoader::dynaLoad"
69: Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() should not be called statically)
70:
71: array(2) {
72: [0]=>
73: string(12) "MyAutoLoader"
74: [1]=>
75: string(8) "notExist"
76: }
77: Passed array does not specify an existing static method (class 'MyAutoLoader' does not have a method 'notExist')
78:
79: array(2) {
80: [0]=>
81: string(12) "MyAutoLoader"
82: [1]=>
83: string(8) "noAccess"
84: }
85: Passed array does not specify a callable static method (cannot access protected method MyAutoLoader::noAccess())
86:
87: array(2) {
88: [0]=>
89: string(12) "MyAutoLoader"
90: [1]=>
91: string(8) "autoLoad"
92: }
93: ok
94:
95: array(2) {
96: [0]=>
97: string(12) "MyAutoLoader"
98: [1]=>
99: string(8) "dynaLoad"
100: }
101: Passed array specifies a non static method but no object (non-static method MyAutoLoader::dynaLoad() should not be called statically)
102:
103: array(2) {
104: [0]=>
105: object(MyAutoLoader)#%d (0) {
106: }
107: [1]=>
108: string(8) "notExist"
109: }
110: Passed array does not specify an existing method (class 'MyAutoLoader' does not have a method 'notExist')
111:
112: array(2) {
113: [0]=>
114: object(MyAutoLoader)#%d (0) {
115: }
116: [1]=>
117: string(8) "noAccess"
118: }
119: Passed array does not specify a callable method (cannot access protected method MyAutoLoader::noAccess())
120:
121: array(2) {
122: [0]=>
123: object(MyAutoLoader)#%d (0) {
124: }
125: [1]=>
126: string(8) "autoLoad"
127: }
128: ok
129:
130: array(2) {
131: [0]=>
132: object(MyAutoLoader)#%d (0) {
133: }
134: [1]=>
135: string(8) "dynaLoad"
136: }
137: ok
138: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>