Add ContentType Injection for HTTPInputData tests

This commit is contained in:
Philipp 2021-05-23 22:40:41 +02:00
parent a69e128fe4
commit 15216266d9
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
3 changed files with 42 additions and 6 deletions

View file

@ -29,7 +29,7 @@ class HTTPInputData
{
public static function process()
{
$content_parts = explode(';', $_SERVER['CONTENT_TYPE'] ?? 'application/x-www-form-urlencoded');
$content_parts = explode(';', static::getContentType());
$boundary = '';
$encoding = '';
@ -263,6 +263,7 @@ class HTTPInputData
/**
* Returns the current PHP input stream
* Mainly used for test doubling
*
* @return false|resource
*/
protected static function getPhpInputStream()
@ -273,10 +274,22 @@ class HTTPInputData
/**
* Returns the content of the current PHP input
* Mainly used for test doubling
*
* @return false|string
*/
protected static function getPhpInputContent()
{
return file_get_contents('php://input');
}
/**
* Returns the content type string of the current call
* Mainly used for test doubling
*
* @return false|string
*/
protected static function getContentType()
{
return $_SERVER['CONTENT_TYPE'] ?? 'application/x-www-form-urlencoded';
}
}