|
|
|
@ -214,4 +214,39 @@ class RequestTest extends \PHPUnit\Framework\TestCase
|
|
|
|
|
// default values
|
|
|
|
|
$this->assertEquals('default value', $request->getHeader('X-Non-Existent-Header', 'default value'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetHeaders()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER = [];
|
|
|
|
|
$_SERVER['HTTP_X_CUSTOM_HEADER'] = 'custom header value';
|
|
|
|
|
$request = new Request();
|
|
|
|
|
$this->assertEquals(['X-Custom-Header' => 'custom header value'], $request->getHeaders());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetHeadersWithEmptyServer()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER = [];
|
|
|
|
|
$request = new Request();
|
|
|
|
|
$this->assertEquals([], $request->getHeaders());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetHeadersWithEmptyHeader()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER = [];
|
|
|
|
|
$_SERVER['HTTP_X_CUSTOM_HEADER'] = '';
|
|
|
|
|
$request = new Request();
|
|
|
|
|
$this->assertEquals(['X-Custom-Header' => ''], $request->getHeaders());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetHeadersWithMultipleHeaders()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER = [];
|
|
|
|
|
$_SERVER['HTTP_X_CUSTOM_HEADER'] = 'custom header value';
|
|
|
|
|
$_SERVER['HTTP_X_CUSTOM_HEADER2'] = 'custom header value 2';
|
|
|
|
|
$request = new Request();
|
|
|
|
|
$this->assertEquals([
|
|
|
|
|
'X-Custom-Header' => 'custom header value',
|
|
|
|
|
'X-Custom-Header2' => 'custom header value 2'
|
|
|
|
|
], $request->getHeaders());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|