You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/Http/Response.error.phpt
+29-19Lines changed: 29 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,6 @@ use Tester\Assert;
10
10
11
11
require__DIR__ . '/../bootstrap.php';
12
12
13
-
if (PHP_SAPI === 'cli') {
14
-
Tester\Environment::skip('Cookies are not available in CLI');
15
-
}
16
-
17
13
18
14
$response = newHttp\Response;
19
15
$response->setHeader('A', 'b'); // no output
@@ -24,18 +20,32 @@ $response->setHeader('A', 'b'); // full buffer
24
20
ob_end_clean();
25
21
26
22
27
-
Assert::error(function () use ($response) {
28
-
ob_start(NULL, 4096);
29
-
echo'';
30
-
$response->setHeader('A', 'b');
31
-
}, E_USER_NOTICE, 'Possible problem: you are sending a HTTP header while already having some data in output buffer%a%');
32
-
33
-
34
-
$response->warnOnBuffer = FALSE;
35
-
$response->setHeader('A', 'b');
36
-
37
-
38
-
Assert::exception(function () use ($response) {
39
-
ob_flush();
40
-
$response->setHeader('A', 'b');
41
-
}, Nette\InvalidStateException::class, 'Cannot send header after HTTP headers have been sent (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ').');
23
+
if (PHP_SAPI === 'cli') {
24
+
Assert::noError(function () use ($response) {
25
+
ob_start(NULL, 4096);
26
+
echo'';
27
+
$response->setHeader('A', 'b');
28
+
});
29
+
30
+
Assert::error(function () use ($response) {
31
+
ob_flush();
32
+
$response->setHeader('A', 'b');
33
+
}, E_WARNING, 'Cannot modify header information - headers already sent by (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ')');
34
+
35
+
} else {
36
+
Assert::error(function () use ($response) {
37
+
ob_start(NULL, 4096);
38
+
echo'';
39
+
$response->setHeader('A', 'b');
40
+
}, E_USER_NOTICE, 'Possible problem: you are sending a HTTP header while already having some data in output buffer%a%');
41
+
42
+
Assert::noError(function () use ($response) {
43
+
$response->warnOnBuffer = FALSE;
44
+
$response->setHeader('A', 'b');
45
+
});
46
+
47
+
Assert::exception(function () use ($response) {
48
+
ob_flush();
49
+
$response->setHeader('A', 'b');
50
+
}, Nette\InvalidStateException::class, 'Cannot send header after HTTP headers have been sent (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ').');
0 commit comments