public function testNormalizeServerReturnsArrayUnalteredIfApacheHeadersDoNotContainAuthorization() { $r = new ReflectionProperty('Phly\\Http\\ServerRequestFactory', 'apacheRequestHeaders'); $r->setAccessible(true); $r->setValue(function () { return []; }); $expected = ['FOO_BAR' => 'BAZ']; $server = ServerRequestFactory::normalizeServer($expected); $this->assertEquals($expected, $server); }
/** * Create a Server instance * * Creates a server instance from the callback and the following * PHP environmental values: * * - server; typically this will be the $_SERVER superglobal * - query; typically this will be the $_GET superglobal * - body; typically this will be the $_POST superglobal * - cookies; typically this will be the $_COOKIE superglobal * - files; typically this will be the $_FILES superglobal * * @param callable $callback * @param array $server * @param array $query * @param array $body * @param array $cookies * @param array $files * @return self */ public static function createServer(callable $callback, array $server, array $query, array $body, array $cookies, array $files) { $request = ServerRequestFactory::fromGlobals($server, $query, $body, $cookies, $files); $response = new Response(); return new self($callback, $request, $response); }
public function __invoke() { return [\Phly\Http\ServerRequest::class => \DI\factory(function () { return \Phly\Http\ServerRequestFactory::fromGlobals(); })]; }