You are here

public function WriteSafeSessionHandlerTest::testConstructWriteSafeSessionHandlerDisableWriting in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testConstructWriteSafeSessionHandlerDisableWriting()
  2. 9 core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php \Drupal\Tests\Core\Session\WriteSafeSessionHandlerTest::testConstructWriteSafeSessionHandlerDisableWriting()

Tests creating a WriteSafeSessionHandler with session writing disabled.

@covers ::__construct @covers ::isSessionWritable @covers ::write

File

core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php, line 68

Class

WriteSafeSessionHandlerTest
Tests \Drupal\Core\Session\WriteSafeSessionHandler.

Namespace

Drupal\Tests\Core\Session

Code

public function testConstructWriteSafeSessionHandlerDisableWriting() {
  $session_id = 'some-id';
  $session_data = 'serialized-session-data';

  // Disable writing upon construction.
  $this->sessionHandler = new WriteSafeSessionHandler($this->wrappedSessionHandler, FALSE);
  $this
    ->assertFalse($this->sessionHandler
    ->isSessionWritable());
  $result = $this->sessionHandler
    ->write($session_id, $session_data);
  $this
    ->assertTrue($result);
}