本文整理汇总了PHP中xdebug_get_headers函数的典型用法代码示例。如果您正苦于以下问题:PHP xdebug_get_headers函数的具体用法?PHP xdebug_get_headers怎么用?PHP xdebug_get_headers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xdebug_get_headers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRespondsPlainTextWithHttpCode404
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode404()
{
(new NotFound())->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::NOT_FOUND, http_response_code());
$this->expectOutputString('Not Found.');
}
示例2: test_send_headers
public function test_send_headers()
{
SecureHeaders::fromFile($this->configPath)->send();
$headers = xdebug_get_headers();
$this->assertContains('X-Content-Type-Options: nosniff', $headers);
$this->assertContains('Referrer-Policy: strict-origin-when-cross-origin', $headers);
}
示例3: testRespondsPlainTextWithHttpCode401
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode401()
{
(new Unauthorized())->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::UNAUTHORIZED, http_response_code());
$this->expectOutputString('Unauthorized.');
}
示例4: testRespondsPlainTextWithHttpCode403
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode403()
{
(new Forbidden())->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::FORBIDDEN, http_response_code());
$this->expectOutputString("Forbidden!");
}
示例5: testSendsLocationAndHttpCodeHeaderWhenResponding
/**
* @runInSeparateProcess
* @dataProvider locationCodeProvider
*/
public function testSendsLocationAndHttpCodeHeaderWhenResponding($location, $httpCode, $expectedHeader, $expectedCode)
{
$redirect = new Redirect($location, $httpCode);
$redirect->respond();
$this->assertContains($expectedHeader, xdebug_get_headers());
$this->assertEquals($expectedCode, http_response_code());
}
示例6: testRespondsPlainTextWithHttpCode405
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode405()
{
(new MethodNotAllowed())->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::METHOD_NOT_ALLOWED, http_response_code());
$this->expectOutputString('Method not allowed.');
}
示例7: testProtectedController
/**
* @runInSeparateProcess
* @outputBuffering disabled
*/
public function testProtectedController()
{
if (!function_exists('xdebug_get_headers')) {
$this->markTestSkipped('Xdebug not installed');
}
$autoloader = new Autoloader();
$autoloader->register();
$autoloader->addNamespaces([['Linna\\FOO', dirname(__DIR__) . '/FOO']]);
//config options
$session = new Session();
$session->start();
$password = new Password();
$storedPassword = $password->hash('password');
//attemp first login
$login = new Login($session, $password);
$login->login('root', 'password', $storedUser = 'root', $storedPassword, 1);
$loginLogged = $login->logged;
$model = new FOOModel();
$controller1 = new FOOProtectedController($model, $login);
$controllerTest1 = $controller1->test;
$login->logout();
$loginNoLogged = $login->logged;
ob_start();
$controller2 = new FOOProtectedController($model, $login);
$headers_list = xdebug_get_headers();
ob_end_clean();
$this->assertEquals(true, $loginLogged);
$this->assertEquals(false, $loginNoLogged);
$this->assertEquals(true, $controllerTest1);
$this->assertEquals(true, in_array('Location: http://localhost', $headers_list));
$session->destroy();
}
示例8: testRespondsPlainTextWithHttpCode500
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode500()
{
(new InternalServerError())->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::INTERNAL_SERVER_ERROR, http_response_code());
$this->expectOutputString("Internal server error.");
}
示例9: shouldShowCaptcha
/**
* @test
*/
public function shouldShowCaptcha()
{
$this->oneClickCaptchaService->showCaptcha();
$headers = xdebug_get_headers();
$this->assertEquals("Expires: Thu, 19 Nov 1981 08:52:00 GMT", $headers[1]);
$this->assertEquals("Pragma: public", $headers[2]);
$this->assertEquals("Cache-Control: public", $headers[3]);
}
示例10: testHeader
/**
* コンテンツタイプを出力
*
* @return void
*/
public function testHeader()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->BcMobile->header();
$result = xdebug_get_headers();
$expected = 'Content-type: application/xhtml+xml';
$this->assertEquals($expected, $result[0]);
}
示例11: testResponseObjectReturnsAllowedHeaderWhenWrongMethodUsed
/**
* @runInSeparateProcess
*/
public function testResponseObjectReturnsAllowedHeaderWhenWrongMethodUsed()
{
$request = $this->container['request'];
$request->setSupportedRequestMethods(array($request::POST, $request::PUT, $request::DELETE));
$response = $this->container['response'];
$this->response->send($response::METHOD_NOT_ALLOWED_CODE);
$this->assertContains('Allow: POST, PUT, DELETE', xdebug_get_headers());
}
示例12: testRespondsPlainTextWithHttpCode400
/**
* @runInSeparateProcess
*/
public function testRespondsPlainTextWithHttpCode400()
{
$messages = ['This is a unit test.', 'I am testing the output.'];
(new BadRequest($messages))->respond();
$this->assertContains('Content-Type: text/plain; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::BAD_REQUEST, http_response_code());
$this->expectOutputString("This is a unit test.\nI am testing the output.");
}
示例13: testJson
/**
* @runInSeparateProcess
*/
public function testJson()
{
$response = new Response($this->makeRequest());
$response->setJson(['a' => 'b']);
$this->expectOutputString(json_encode(['a' => 'b', 'c' => 'd']));
$response->json(['c' => 'd']);
$this->assertContains('Content-type: application/json', xdebug_get_headers());
}
示例14: testRespondsJsonWithHttpCode500
/**
* @runInSeparateProcess
*/
public function testRespondsJsonWithHttpCode500()
{
$messages = ['This is a unit test.', 'I am testing the output.'];
(new BadJsonRequest($messages))->respond();
$this->assertContains('Content-Type: application/json; charset=utf-8', xdebug_get_headers());
$this->assertEquals(Http::BAD_REQUEST, http_response_code());
$this->expectOutputString('{"messages":["This is a unit test.","I am testing the output."]}');
}
示例15: testHeaderResponseAttributes
/**
* @test
* @requires PHP > 5.3
* @runInSeparateProcess
*/
public function testHeaderResponseAttributes()
{
$this->qrCode->setFormat('png')->setHeaderResponse();
$this->assertEquals(['Content-Type: image/png'], \xdebug_get_headers());
$this->qrCode->setFormat('jpg')->setHeaderResponse();
$this->assertEquals(['Content-Type: image/jpeg'], \xdebug_get_headers());
$this->qrCode->setFormat('gif')->setHeaderResponse();
$this->assertEquals(['Content-Type: image/gif'], \xdebug_get_headers());
}