function SessionTest::testSessionWriteError

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/Session/SessionTest.php \Drupal\Tests\system\Functional\Session\SessionTest::testSessionWriteError()

Test exception thrown during session write close.

File

core/modules/system/tests/src/Functional/Session/SessionTest.php, line 364

Class

SessionTest
Drupal session handling tests.

Namespace

Drupal\Tests\system\Functional\Session

Code

public function testSessionWriteError() : void {
    // Login to ensure a session exists.
    $user = $this->drupalCreateUser([]);
    $this->drupalLogin($user);
    // Trigger an exception in SessionHandler::write().
    $this->expectExceptionMessageMatches("/^Drupal\\\\Core\\\\Database\\\\DatabaseExceptionWrapper:/");
    $this->drupalGet('/session-test/trigger-write-exception');
    $this->assertSession()
        ->statusCodeEquals(500);
}

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