$server =
[ 'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' =>
$this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::
create('/subdir/', 'GET',
[],
[],
[],
$server);
$request->attributes->
set(RouteObjectInterface::ROUTE_NAME, '<front>'
);
$request->attributes->
set(RouteObjectInterface::ROUTE_OBJECT,
new Route('/'
));
$request_stack->
push($request);
$request_context->
fromRequest($request);
$url = GeneratedUrl::
createFromObject($expected_cacheability)->
setGeneratedUrl('/subdir/'
);
$this->
assertEquals($this->urlGenerator->
generateFromRoute('<current>',
[],
[], TRUE
),
$url);
// Test request with subdir on other page.
$server =
[ 'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' =>
$this->root . '/index.php',
'SERVER_NAME' => 'http://www.example.com',
];
$request = Request::
create('/subdir/node/add', 'GET',
[],
[],
[],
$server);
$request->attributes->
set(RouteObjectInterface::ROUTE_NAME, 'node.add'
);
$request->attributes->
set(RouteObjectInterface::ROUTE_OBJECT,
new Route('/node/add'
));