|
|
@@ -53,6 +53,7 @@ use Cake\Utility\Hash;
|
|
|
use Cake\Utility\Security;
|
|
|
use Cake\Utility\Text;
|
|
|
use Cake\View\Helper\SecureFieldTokenTrait;
|
|
|
+use Zend\Diactoros\Uri;
|
|
|
use Exception;
|
|
|
use LogicException;
|
|
|
use PHPUnit\Exception as PhpunitException;
|
|
|
@@ -610,7 +611,7 @@ trait IntegrationTestTrait
|
|
|
];
|
|
|
$session = Session::create($sessionConfig);
|
|
|
$session->write($this->_session);
|
|
|
- list($url, $query) = $this->_url($url);
|
|
|
+ list($url, $query, $hostInfo) = $this->_url($url);
|
|
|
$tokenUrl = $url;
|
|
|
|
|
|
if ($query) {
|
|
|
@@ -638,6 +639,12 @@ trait IntegrationTestTrait
|
|
|
'QUERY_STRING' => $query,
|
|
|
'REQUEST_URI' => $url,
|
|
|
];
|
|
|
+ if (!empty($hostInfo['ssl'])) {
|
|
|
+ $env['HTTPS'] = 'on';
|
|
|
+ }
|
|
|
+ if (isset($hostInfo['host'])) {
|
|
|
+ $env['HTTP_HOST'] = $hostInfo['host'];
|
|
|
+ }
|
|
|
if (isset($this->_request['headers'])) {
|
|
|
foreach ($this->_request['headers'] as $k => $v) {
|
|
|
$name = strtoupper(str_replace('-', '_', $k));
|
|
|
@@ -717,23 +724,23 @@ trait IntegrationTestTrait
|
|
|
* Creates a valid request url and parameter array more like Request::_url()
|
|
|
*
|
|
|
* @param string|array $url The URL
|
|
|
- * @return array Qualified URL and the query parameters
|
|
|
+ * @return array Qualified URL, the query parameters, and host data
|
|
|
*/
|
|
|
protected function _url($url)
|
|
|
{
|
|
|
- // re-create URL in ServerRequest's context so
|
|
|
- // query strings are encoded as expected
|
|
|
- $request = new ServerRequest(['url' => $url]);
|
|
|
- $url = $request->getRequestTarget();
|
|
|
+ $uri = new Uri($url);
|
|
|
+ $path = $uri->getPath();
|
|
|
+ $query = $uri->getQuery();
|
|
|
|
|
|
- $query = '';
|
|
|
-
|
|
|
- $path = parse_url($url, PHP_URL_PATH);
|
|
|
- if (strpos($url, '?') !== false) {
|
|
|
- $query = parse_url($url, PHP_URL_QUERY);
|
|
|
+ $hostData = [];
|
|
|
+ if ($uri->getHost()) {
|
|
|
+ $hostData['host'] = $uri->getHost();
|
|
|
+ }
|
|
|
+ if ($uri->getScheme()) {
|
|
|
+ $hostData['ssl'] = $uri->getScheme() === 'https';
|
|
|
}
|
|
|
|
|
|
- return [$path, $query];
|
|
|
+ return [$path, $query, $hostData];
|
|
|
}
|
|
|
|
|
|
/**
|