ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Environment.php
Go to the documentation of this file.
1<?php
9namespace Slim\Http;
10
13
22{
30 public static function mock(array $userData = [])
31 {
32 //Validates if default protocol is HTTPS to set default port 443
33 if ((isset($userData['HTTPS']) && $userData['HTTPS'] !== 'off') ||
34 ((isset($userData['REQUEST_SCHEME']) && $userData['REQUEST_SCHEME'] === 'https'))) {
35 $defscheme = 'https';
36 $defport = 443;
37 } else {
38 $defscheme = 'http';
39 $defport = 80;
40 }
41
42 $data = array_merge([
43 'SERVER_PROTOCOL' => 'HTTP/1.1',
44 'REQUEST_METHOD' => 'GET',
45 'REQUEST_SCHEME' => $defscheme,
46 'SCRIPT_NAME' => '',
47 'REQUEST_URI' => '',
48 'QUERY_STRING' => '',
49 'SERVER_NAME' => 'localhost',
50 'SERVER_PORT' => $defport,
51 'HTTP_HOST' => 'localhost',
52 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
53 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
54 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
55 'HTTP_USER_AGENT' => 'Slim Framework',
56 'REMOTE_ADDR' => '127.0.0.1',
57 'REQUEST_TIME' => time(),
58 'REQUEST_TIME_FLOAT' => microtime(true),
59 ], $userData);
60
61 return new static($data);
62 }
63}
An exception for terminatinating execution or to throw for unit testing.
Collection.
Definition: Collection.php:22
static mock(array $userData=[])
Create mock environment.
Definition: Environment.php:30
Slim Framework (https://slimframework.com)
Definition: Body.php:9