Annotation of embedaddon/php/ext/standard/tests/assert/assert_variation.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: assert() - variation - test callback options using ini_get/ini_set/assert_options
3: --INI--
4: assert.active = 1
5: assert.warning = 0
6: assert.callback = f1
7: assert.bail = 0
8: assert.quiet_eval = 0
9: --FILE--
10: <?php
11: function f1()
12: {
13: echo "f1 called\n";
14: }
15: function f2()
16: {
17: echo "f2 called\n";
18: }
19: function f3()
20: {
21: echo "f3 called\n";
22: }
23: class c1
24: {
25: function assert($file, $line, $myev)
26: {
27: echo "Class assertion failed $line, \"$myev\"\n";
28: }
29: }
30: echo "Initial values: assert_options(ASSERT_CALLBACK) => [".assert_options(ASSERT_CALLBACK)."]\n";
31: echo "Initial values: ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n";
32: $sa = "0 != 0";
33: var_dump($r2=assert($sa));
34: echo"\n";
35:
36: echo "Change callback function using ini.set and test return value \n";
37: var_dump($rv = ini_set("assert.callback","f2"));
38: echo "assert_options(ASSERT_CALLBACK) => [".assert_options(ASSERT_CALLBACK)."]\n";
39: echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n";
40: var_dump($r2=assert($sa));
41: echo"\n";
42:
43: echo "Change callback function using assert_options and test return value \n";
44: var_dump($rv=assert_options(ASSERT_CALLBACK, "f3"));
45: echo "assert_options(ASSERT_CALLBACK) => [".assert_options(ASSERT_CALLBACK)."]\n";
46: echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n";
47: var_dump($r2=assert($sa));
48: echo"\n";
49:
50:
51: echo "Reset the name of the callback routine to a class method and check that it works\n";
52: var_dump($rc=assert_options(ASSERT_CALLBACK, "c1"));
53: echo "assert_options(ASSERT_CALLBACK) => [".assert_options(ASSERT_CALLBACK)."]\n";
54: echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n";
55: var_dump($r2=assert($sa));
56: echo"\n";
57:
58: echo "Reset callback options to use a class method \n";
59: var_dump($rc = assert_options(ASSERT_CALLBACK,array("c1","assert")));
60: var_dump($rao=assert_options(ASSERT_CALLBACK));
61: echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n\n";
62: var_dump($r2=assert($sa));
63: echo"\n";
64:
65: echo "Reset callback options to use an object method \n";
66: $o = new c1();
67: var_dump($rc=assert_options(ASSERT_CALLBACK,array(&$o,"assert")));
68: var_dump($rao=assert_options(ASSERT_CALLBACK));
69: echo "ini.get(\"assert.callback\") => [".ini_get("assert.callback")."]\n\n";
70: var_dump($r2=assert($sa));
71: echo"\n";
72:
73: --EXPECTF--
74: Initial values: assert_options(ASSERT_CALLBACK) => [f1]
75: Initial values: ini.get("assert.callback") => [f1]
76: f1 called
77: NULL
78:
79: Change callback function using ini.set and test return value
80: string(2) "f1"
81: assert_options(ASSERT_CALLBACK) => [f2]
82: ini.get("assert.callback") => [f2]
83: f2 called
84: NULL
85:
86: Change callback function using assert_options and test return value
87: string(2) "f2"
88: assert_options(ASSERT_CALLBACK) => [f3]
89: ini.get("assert.callback") => [f2]
90: f3 called
91: NULL
92:
93: Reset the name of the callback routine to a class method and check that it works
94: string(2) "f3"
95: assert_options(ASSERT_CALLBACK) => [c1]
96: ini.get("assert.callback") => [f2]
97: NULL
98:
99: Reset callback options to use a class method
100: string(2) "c1"
101: array(2) {
102: [0]=>
103: string(2) "c1"
104: [1]=>
105: string(6) "assert"
106: }
107: ini.get("assert.callback") => [f2]
108:
109:
110: Strict Standards: Non-static method c1::assert() should not be called statically in %s on line 53
111: Class assertion failed 53, "0 != 0"
112: NULL
113:
114: Reset callback options to use an object method
115: array(2) {
116: [0]=>
117: string(2) "c1"
118: [1]=>
119: string(6) "assert"
120: }
121: array(2) {
122: [0]=>
123: &object(c1)#1 (0) {
124: }
125: [1]=>
126: string(6) "assert"
127: }
128: ini.get("assert.callback") => [f2]
129:
130: Class assertion failed 61, "0 != 0"
131: NULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>