function ComponentTranslationTest::request
Passes a request to the HTTP kernel and returns a response.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
\Symfony\Component\HttpFoundation\Response The response.
File
-
core/
tests/ Drupal/ KernelTests/ Components/ ComponentTranslationTest.php, line 164
Class
- ComponentTranslationTest
- Tests the component can be translated.
Namespace
Drupal\KernelTests\ComponentsCode
protected function request(Request $request) : Response {
// @todo We should replace this when https://drupal.org/i/3390193 lands.
// Reset the request stack.
// \Drupal\KernelTests\KernelTestBase::bootKernel() pushes a bogus request
// to boot the kernel, but it is also needed for any URL generation in tests
// to work. We also need to reset the request stack every time we make a
// request.
$request_stack = $this->container
->get('request_stack');
while ($request_stack->getCurrentRequest() !== NULL) {
$request_stack->pop();
}
$http_kernel = $this->container
->get('http_kernel');
self::assertInstanceOf(HttpKernelInterface::class, $http_kernel);
$response = $http_kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, FALSE);
$content = $response->getContent();
self::assertNotFalse($content);
$this->setRawContent($content);
self::assertInstanceOf(TerminableInterface::class, $http_kernel);
$http_kernel->terminate($request, $response);
return $response;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.