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]
75f1 called
76bool(false)
77
78Change callback function using ini.set and test return value
79string(2) "f1"
80assert_options(ASSERT_CALLBACK) => [f2]
81ini.get("assert.callback") => [f2]
82f2 called
83bool(false)
84
85Change callback function using assert_options and test return value
86string(2) "f2"
87assert_options(ASSERT_CALLBACK) => [f3]
88ini.get("assert.callback") => [f2]
89f3 called
90bool(false)
91
92Reset the name of the callback routine to a class method and check that it works
93string(2) "f3"
94assert_options(ASSERT_CALLBACK) => [c1]
95ini.get("assert.callback") => [f2]
96bool(false)
97
98Reset callback options to use a class method
99string(2) "c1"
100array(2) {
101  [0]=>
102  string(2) "c1"
103  [1]=>
104  string(6) "assert"
105}
106ini.get("assert.callback") => [f2]
107
108
109Deprecated: Non-static method c1::assert() should not be called statically in %s on line 53
110Class assertion failed 53, "0 != 0"
111bool(false)
112
113Reset callback options to use an object method
114array(2) {
115  [0]=>
116  string(2) "c1"
117  [1]=>
118  string(6) "assert"
119}
120array(2) {
121  [0]=>
122  &object(c1)#1 (0) {
123  }
124  [1]=>
125  string(6) "assert"
126}
127ini.get("assert.callback") => [f2]
128
129Class assertion failed 61, "0 != 0"
130bool(false)
131