function SessionTest::testSessionWriteError

Same name in other branches
  1. 11.x 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 365

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.