function StackKernelIntegrationTest::testRequest

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php \Drupal\KernelTests\Core\HttpKernel\StackKernelIntegrationTest::testRequest()
  2. 10 core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php \Drupal\KernelTests\Core\HttpKernel\StackKernelIntegrationTest::testRequest()
  3. 11.x 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 35

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::MASTER_REQUEST, FALSE);
    $this->assertEqual($request->attributes
        ->get('_hello'), 'world');
    $this->assertEqual($request->attributes
        ->get('_previous_optional_argument'), 'test_argument');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.