|
|
@ -164,11 +164,7 @@ class ResponseTest extends TestCase
|
|
|
|
$response->cache(false);
|
|
|
|
$response->cache(false);
|
|
|
|
$this->assertEquals([
|
|
|
|
$this->assertEquals([
|
|
|
|
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
|
|
|
|
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
|
|
|
|
'Cache-Control' => [
|
|
|
|
'Cache-Control' => 'no-store, no-cache, must-revalidate',
|
|
|
|
'no-store, no-cache, must-revalidate',
|
|
|
|
|
|
|
|
'post-check=0, pre-check=0',
|
|
|
|
|
|
|
|
'max-age=0',
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'Pragma' => 'no-cache'
|
|
|
|
'Pragma' => 'no-cache'
|
|
|
|
], $response->headers());
|
|
|
|
], $response->headers());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -239,6 +235,46 @@ class ResponseTest extends TestCase
|
|
|
|
$this->assertTrue($response->sent());
|
|
|
|
$this->assertTrue($response->sent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testSendWithNoHeadersSent()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$response = new class extends Response {
|
|
|
|
|
|
|
|
protected $test_sent_headers = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setRealHeader(string $header_string, bool $replace = true, int $response_code = 0): self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->test_sent_headers[] = $header_string;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getSentHeaders(): array
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->test_sent_headers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function headersSent(): bool
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
$response->header('Content-Type', 'text/html');
|
|
|
|
|
|
|
|
$response->header('X-Test', 'test');
|
|
|
|
|
|
|
|
$response->write('Something');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->expectOutputString('Something');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response->send();
|
|
|
|
|
|
|
|
$sent_headers = $response->getSentHeaders();
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
|
|
|
'HTTP/1.1 200 OK',
|
|
|
|
|
|
|
|
'Content-Type: text/html',
|
|
|
|
|
|
|
|
'X-Test: test',
|
|
|
|
|
|
|
|
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
|
|
|
|
|
|
|
|
'Cache-Control: no-store, no-cache, must-revalidate',
|
|
|
|
|
|
|
|
'Pragma: no-cache',
|
|
|
|
|
|
|
|
'Content-Length: 9'
|
|
|
|
|
|
|
|
], $sent_headers);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testClearBody()
|
|
|
|
public function testClearBody()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$response = new Response();
|
|
|
|
$response = new Response();
|
|
|
|