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