-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from inhere/inhere-patch-1
Update some
- Loading branch information
Showing
2 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Inhere | ||
* Date: 2015/2/27 | ||
* Use : ... | ||
* File: Environment.php | ||
*/ | ||
|
||
namespace Inhere\Http\Component; | ||
|
||
/** | ||
* mock 环境信息 | ||
* Class Environment | ||
* @package Inhere\Http\Component | ||
*/ | ||
class Environment extends Collection | ||
{ | ||
/** | ||
* Create mock environment | ||
* @param array $userData Array of custom environment keys and values | ||
* @return self | ||
*/ | ||
public static function mock(array $userData = []): self | ||
{ | ||
$data = \array_merge([ | ||
'SERVER_PROTOCOL' => 'HTTP/1.1', | ||
'REQUEST_METHOD' => 'GET', | ||
'SCRIPT_NAME' => '', | ||
'REQUEST_URI' => '', | ||
'QUERY_STRING' => '', | ||
'SERVER_NAME' => 'localhost', | ||
'SERVER_PORT' => 80, | ||
'HTTP_HOST' => 'localhost', | ||
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | ||
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', | ||
'HTTP_ACCEPT_CHARSET' => 'utf-8;q=0.7,*;q=0.3', | ||
'HTTP_USER_AGENT' => 'Slim Framework', | ||
'REMOTE_ADDR' => '127.0.0.1', | ||
'REQUEST_TIME' => \time(), | ||
'REQUEST_TIME_FLOAT' => \microtime(true), | ||
], $userData); | ||
|
||
return new static($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters