When called from a command-line process, this function does nothing when passed a specific header to remove, but it does nonetheless work properly when called with no arguments to remove all headers.
Thus, when unit-testing or executing in some other test harness, if the code you are testing may call `header_remove()`, with the UOPZ and XDebug extensions loaded, you could use the following in order to more effectively test that the expected headers are set [which you would do by inspecting the array returned by `xdebug_get_headers()` after running the code under test, as `headers_list()` does not work despite the headers actually being stored internally as normal]:
<?php
uopz_set_return(
'header_remove',
function($name = null) {
if ($name !== null) {
$pattern = '/^' . preg_quote($name, '/') . ':/i';
$headers = array_filter(
xdebug_get_headers(),
function($header) use($pattern) {
return !preg_match($pattern, $header);
}
);
}
header_remove();
if ($name !== null) {
foreach ($headers as $header) {
header($header);
}
}
},
true
);
?>