You are here

public function StackKernelIntegrationTest::testRequest in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php \Drupal\KernelTests\Core\HttpKernel\StackKernelIntegrationTest::testRequest()
  2. 9 core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php \Drupal\KernelTests\Core\HttpKernel\StackKernelIntegrationTest::testRequest()

Tests a request.

File

core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php, line 27

Class

StackKernelIntegrationTest
Tests the stacked kernel functionality.

Namespace

Drupal\KernelTests\Core\HttpKernel

Code

public function testRequest() {
  $request = Request::create((new Url('httpkernel_test.empty'))
    ->toString());

  /** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
  $http_kernel = \Drupal::service('http_kernel');
  $http_kernel
    ->handle($request, HttpKernelInterface::MAIN_REQUEST, FALSE);
  $this
    ->assertEquals('world', $request->attributes
    ->get('_hello'));
  $this
    ->assertEquals('test_argument', $request->attributes
    ->get('_previous_optional_argument'));
}