mirror of
https://github.com/friendica/friendica
synced 2025-04-22 00:30:10 +00:00
Enable testability for HTTPInputData and create a failing test for it :-)
This commit is contained in:
parent
fd3706b72e
commit
a0da84b6b0
3 changed files with 162 additions and 2 deletions
|
@ -58,7 +58,7 @@ class HTTPInputData
|
|||
}
|
||||
|
||||
// can be handled by built in PHP functionality
|
||||
$content = file_get_contents('php://input');
|
||||
$content = static::getPhpInputContent();
|
||||
|
||||
$variables = json_decode($content);
|
||||
|
||||
|
@ -73,7 +73,7 @@ class HTTPInputData
|
|||
{
|
||||
$result = ['variables' => [], 'files' => []];
|
||||
|
||||
$stream = fopen('php://input', 'rb');
|
||||
$stream = static::getPhpInputStream();
|
||||
|
||||
$sanity = fgets($stream, strlen($boundary) + 5);
|
||||
|
||||
|
@ -259,4 +259,24 @@ class HTTPInputData
|
|||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current PHP input stream
|
||||
* Mainly used for test doubling
|
||||
* @return false|resource
|
||||
*/
|
||||
protected static function getPhpInputStream()
|
||||
{
|
||||
return fopen('php://input', 'rb');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of tje current PHP input
|
||||
* Mainly used for test doubling
|
||||
* @return false|string
|
||||
*/
|
||||
protected static function getPhpInputContent()
|
||||
{
|
||||
return file_get_contents('php://input');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue