本文整理汇总了PHP中Sabre\HTTP\Request::createFromServerArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::createFromServerArray方法的具体用法?PHP Request::createFromServerArray怎么用?PHP Request::createFromServerArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\HTTP\Request
的用法示例。
在下文中一共展示了Request::createFromServerArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: request
/**
* Makes a request, and returns a response object.
*
* You can either pass an instance of Sabre\HTTP\Request, or an array,
* which will then be used as the _SERVER array.
*
* @param array|\Sabre\HTTP\Request $request
* @return \Sabre\HTTP\Response
*/
function request($request)
{
if (is_array($request)) {
$request = HTTP\Request::createFromServerArray($request);
}
$this->server->httpRequest = $request;
$this->server->httpResponse = new HTTP\ResponseMock();
$this->server->exec();
return $this->server->httpResponse;
}
示例2: request
/**
* Makes a request, and returns a response object.
*
* You can either pass an instance of Sabre\HTTP\Request, or an array,
* which will then be used as the _SERVER array.
*
* If $expectedStatus is set, we'll compare it with the HTTP status of
* the returned response. If it doesn't match, we'll immediately fail
* the test.
*
* @param array|\Sabre\HTTP\Request $request
* @param int $expectedStatus
* @return \Sabre\HTTP\Response
*/
function request($request, $expectedStatus = null)
{
if (is_array($request)) {
$request = HTTP\Request::createFromServerArray($request);
}
$response = new HTTP\ResponseMock();
$this->server->httpRequest = $request;
$this->server->httpResponse = $response;
$this->server->exec();
if ($expectedStatus) {
$responseBody = $expectedStatus !== $response->getStatus() ? $response->getBodyAsString() : '';
$this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: ' . $responseBody);
}
return $this->server->httpResponse;
}