You are here

public function StackSessionHandlerIntegrationTest::testRequest in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php \Drupal\Tests\system\Functional\Session\StackSessionHandlerIntegrationTest::testRequest()
  2. 10 core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php \Drupal\Tests\system\Functional\Session\StackSessionHandlerIntegrationTest::testRequest()

Tests a request.

File

core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php, line 28

Class

StackSessionHandlerIntegrationTest
Tests the stacked session handler functionality.

Namespace

Drupal\Tests\system\Functional\Session

Code

public function testRequest() {
  $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
  $headers[] = 'X-Requested-With: XMLHttpRequest';
  $actual_trace = json_decode($this
    ->drupalGet('session-test/trace-handler', $options, $headers));
  $sessionId = $this
    ->getSessionCookies()
    ->getCookieByName($this
    ->getSessionName())
    ->getValue();
  $expect_trace = [
    [
      'BEGIN',
      'test_argument',
      'open',
    ],
    [
      'BEGIN',
      NULL,
      'open',
    ],
    [
      'END',
      NULL,
      'open',
    ],
    [
      'END',
      'test_argument',
      'open',
    ],
    [
      'BEGIN',
      'test_argument',
      'read',
      $sessionId,
    ],
    [
      'BEGIN',
      NULL,
      'read',
      $sessionId,
    ],
    [
      'END',
      NULL,
      'read',
      $sessionId,
    ],
    [
      'END',
      'test_argument',
      'read',
      $sessionId,
    ],
    [
      'BEGIN',
      'test_argument',
      'write',
      $sessionId,
    ],
    [
      'BEGIN',
      NULL,
      'write',
      $sessionId,
    ],
    [
      'END',
      NULL,
      'write',
      $sessionId,
    ],
    [
      'END',
      'test_argument',
      'write',
      $sessionId,
    ],
    [
      'BEGIN',
      'test_argument',
      'close',
    ],
    [
      'BEGIN',
      NULL,
      'close',
    ],
    [
      'END',
      NULL,
      'close',
    ],
    [
      'END',
      'test_argument',
      'close',
    ],
  ];
  $this
    ->assertEqual($expect_trace, $actual_trace);
}