Skip to content

Commit

Permalink
fix $_SERVER emulation for POST test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Sep 26, 2023
1 parent 28102e0 commit 6143477
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/DemosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ protected function setSuperglobalsFromRequest(RequestInterface $request): void
$requestQuery = $request->getUri()->getQuery();
$_SERVER = [
'REQUEST_METHOD' => $request->getMethod(),
'HTTP_HOST' => $request->getUri()->getHost(),
'REQUEST_URI' => $requestPath . ($requestQuery !== '' ? '?' . $requestQuery : ''),
'QUERY_STRING' => $requestQuery,
'DOCUMENT_ROOT' => $rootDirRealpath,
'SCRIPT_FILENAME' => $rootDirRealpath . $requestPath,
];
foreach (array_keys($request->getHeaders()) as $k) {
$kSever = 'HTTP_' . str_replace('-', '_', strtoupper($k));
$_SERVER[$kSever] = $request->getHeaderLine($k);
}

$_GET = [];
parse_str($requestQuery, $queryArr);
Expand Down

0 comments on commit 6143477

Please sign in to comment.