Test apache_request_headers in ServerRequestTest
This commit is contained in:
parent
dea577fdb4
commit
9c768793db
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a dummy apache_request_headers method in the global namesapce.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!function_exists("apache_request_headers")) {
|
||||||
|
function apache_request_headers() {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// This file must be in the global namespace to add apache_request_headers
|
|
||||||
|
|
||||||
use WellRESTed\Message\ServerRequest;
|
|
||||||
|
|
||||||
class ApacheRequestHeadersTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @covers WellRESTed\Message\ServerRequest::getServerRequestHeaders
|
|
||||||
* @uses WellRESTed\Message\ServerRequest::getServerRequest
|
|
||||||
* @runInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
*/
|
|
||||||
public function testReadsApacheRequestHeaders()
|
|
||||||
{
|
|
||||||
if (!function_exists("apache_request_headers")) {
|
|
||||||
function apache_request_headers() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$_SERVER = [
|
|
||||||
"HTTP_HOST" => "localhost",
|
|
||||||
"HTTP_ACCEPT" => "application/json",
|
|
||||||
"QUERY_STRING" => "guinea_pig=Claude&hamster=Fizzgig"
|
|
||||||
];
|
|
||||||
$_COOKIE = [
|
|
||||||
"cat" => "Molly"
|
|
||||||
];
|
|
||||||
$_FILES = [
|
|
||||||
"file" => [
|
|
||||||
"name" => "MyFile.jpg",
|
|
||||||
"type" => "image/jpeg",
|
|
||||||
"tmp_name" => "/tmp/php/php6hst32",
|
|
||||||
"error" => "UPLOAD_ERR_OK",
|
|
||||||
"size" => 98174
|
|
||||||
]
|
|
||||||
];
|
|
||||||
$_POST = [
|
|
||||||
"dog" => "Bear"
|
|
||||||
];
|
|
||||||
|
|
||||||
$request = ServerRequest::getServerRequest();
|
|
||||||
$headers = $request->getHeaders();
|
|
||||||
$this->assertNotNull($headers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -285,6 +285,42 @@ class ServerRequestTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals("Molly", $attributes["cat"]);
|
$this->assertEquals("Molly", $attributes["cat"]);
|
||||||
$this->assertEquals("Bear", $attributes["dog"]);
|
$this->assertEquals("Bear", $attributes["dog"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers WellRESTed\Message\ServerRequest::getServerRequestHeaders
|
||||||
|
* @runInSeparateProcess
|
||||||
|
* @preserveGlobalState disabled
|
||||||
|
*/
|
||||||
|
public function testReadsApacheRequestHeaders()
|
||||||
|
{
|
||||||
|
// This file adds a dummy apache_request_headers in the global namespace.
|
||||||
|
require_once(__DIR__ . "/../../../src/apache_request_headers.php");
|
||||||
|
|
||||||
|
$_SERVER = [
|
||||||
|
"HTTP_HOST" => "localhost",
|
||||||
|
"HTTP_ACCEPT" => "application/json",
|
||||||
|
"QUERY_STRING" => "guinea_pig=Claude&hamster=Fizzgig"
|
||||||
|
];
|
||||||
|
$_COOKIE = [
|
||||||
|
"cat" => "Molly"
|
||||||
|
];
|
||||||
|
$_FILES = [
|
||||||
|
"file" => [
|
||||||
|
"name" => "MyFile.jpg",
|
||||||
|
"type" => "image/jpeg",
|
||||||
|
"tmp_name" => "/tmp/php/php6hst32",
|
||||||
|
"error" => "UPLOAD_ERR_OK",
|
||||||
|
"size" => 98174
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$_POST = [
|
||||||
|
"dog" => "Bear"
|
||||||
|
];
|
||||||
|
|
||||||
|
$request = ServerRequest::getServerRequest();
|
||||||
|
$headers = $request->getHeaders();
|
||||||
|
$this->assertNotNull($headers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue