I’m trying to override the setcookie implementation using the test_helpers PECL extension without any luck.
$username = 'test';
set_setcookie_overload(function() { error_log('setcookie called'); return FALSE; });
setcookie('username', $userName, time()+60*60*24*365, '/');
unset_setcookie_overload();
I get this error:
PHP Fatal error: Call to undefined function set_setcookie_overload()
I verified that the extension is working well with the example here: https://github.com/sebastianbergmann/php-test-helpers
Thanks.
Update: For further clarification, it sounds like the test_helpers extension allows to override in-built PHP functions like setcookie. In the link above, the author has provided an example to override the exit method using set_exit_overload(). I’m trying to do the same for setcookie() using set_setcookie_overload() without any luck.
The functions that are available in can be found in the source
over at github. Everything starting withPHP_FUNCTIONis exposed to the user to call.So yeah. There just is no
set_setcookie_overload()in php-test-helpers. You have to find another workaround.Sadly
rename_functioncan’t help you either as it doesn’t work with internal functions.Complete function list of the test_helpers extension