/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/TestSuite
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/TestSuite/MiddlewareDispatcher.php (4224B)
app = $app;
}
/**
* Resolve the provided URL into a string.
*
* @param array|string $url The URL array/string to resolve.
* @return string
*/
public function resolveUrl($url): string
{
// If we need to resolve a Route URL but there are no routes, load routes.
if (is_array($url) && count(Router::getRouteCollection()->routes()) === 0) {
return $this->resolveRoute($url);
}
return Router::url($url);
}
/**
* Convert a URL array into a string URL via routing.
*
* @param array $url The url to resolve
* @return string
*/
protected function resolveRoute(array $url): string
{
// Simulate application bootstrap and route loading.
// We need both to ensure plugins are loaded.
$this->app->bootstrap();
if ($this->app instanceof PluginApplicationInterface) {
$this->app->pluginBootstrap();
}
$builder = Router::createRouteBuilder('/');
if ($this->app instanceof RoutingApplicationInterface) {
$this->app->routes($builder);
}
if ($this->app instanceof PluginApplicationInterface) {
$this->app->pluginRoutes($builder);
}
$out = Router::url($url);
Router::resetRoutes();
return $out;
}
/**
* Create a PSR7 request from the request spec.
*
* @param array
$spec The request spec.
* @return \Cake\Http\ServerRequest
*/
protected function _createRequest(array $spec): ServerRequest
{
if (isset($spec['input'])) {
$spec['post'] = [];
$spec['environment']['CAKEPHP_INPUT'] = $spec['input'];
}
$environment = array_merge(
array_merge($_SERVER, ['REQUEST_URI' => $spec['url']]),
$spec['environment']
);
if (strpos($environment['PHP_SELF'], 'phpunit') !== false) {
$environment['PHP_SELF'] = '/';
}
$request = ServerRequestFactory::fromGlobals(
$environment,
$spec['query'],
$spec['post'],
$spec['cookies'],
$spec['files']
);
return $request
->withAttribute('session', $spec['session'])
->withAttribute('flash', new FlashMessage($spec['session']));
}
/**
* Run a request and get the response.
*
* @param array $requestSpec The request spec to execute.
* @return \Psr\Http\Message\ResponseInterface The generated response.
* @throws \LogicException
*/
public function execute(array $requestSpec): ResponseInterface
{
$server = new Server($this->app);
return $server->run($this->_createRequest($requestSpec));
}
}