Skip to content

Commit ffbb779

Browse files
committed
test: centralize native header function mocks
1 parent 5fd85ab commit ffbb779

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of CodeIgniter 4 framework.
7+
*
8+
* (c) CodeIgniter Foundation <admin@codeigniter.com>
9+
*
10+
* For the full copyright and license information, please view
11+
* the LICENSE file that was distributed with this source code.
12+
*/
13+
14+
namespace CodeIgniter\Debug;
15+
16+
use CodeIgniter\Test\Utilities\NativeHeadersStack;
17+
18+
/**
19+
* Mock implementation of the native PHP `headers_sent()` function.
20+
*
21+
* Instead of checking the actual PHP output buffer, this function
22+
* checks the static property in NativeHeadersStack.
23+
*
24+
* @return bool True if headers are considered sent, false otherwise.
25+
*/
26+
function headers_sent(): bool
27+
{
28+
return NativeHeadersStack::headersSent();
29+
}
30+
31+
/**
32+
* Mock implementation of the native PHP `headers_list()` function.
33+
*
34+
* Retrieves the array of headers stored in the NativeHeadersStack class
35+
* rather than the actual headers sent by the server.
36+
*
37+
* @return array The list of simulated headers.
38+
*/
39+
function headers_list(): array
40+
{
41+
return NativeHeadersStack::listHeaders();
42+
}

0 commit comments

Comments
 (0)