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