// Test to make sure that we generated something for each token.
$this->
assertNotContains(0,
array_map('strlen',
$tests), 'No empty tokens generated.'
);
foreach ($tests as $input =>
$expected) { $bubbleable_metadata =
new BubbleableMetadata();
$output =
$this->tokenService->
replace($input,
[],
['langcode' =>
$this->interfaceLanguage->
getId()],
$bubbleable_metadata);
$this->
assertEquals($expected,
$output,
new FormattableMarkup('System site information token %token replaced.',
['%token' =>
$input]));
$this->
assertEquals($metadata_tests[$input],
$bubbleable_metadata);
} // Test [site:base-url] and [site:base-path] token with a subdirectory.
$request_stack = \Drupal::
requestStack();
// Test request with subdirectory on homepage.
$server =
[ 'SCRIPT_NAME' => '/subdir/index.php',
'SCRIPT_FILENAME' =>
$this->root . '/subdir/index.php',
'SERVER_NAME' => 'http://localhost',
];
$request = Request::
create('/subdir/', 'GET',
[],
[],
[],
$server);
$request->server->
add($server);
$request_stack->
push($request);
$bubbleable_metadata =
new BubbleableMetadata();
$this->container->
get('router.request_context'
)->
setCompleteBaseUrl('http://localhost/subdir'
);