function LegacySessionTest::testLegacyDataPersistence
Tests data persistence via the session_test module callbacks.
File
-
core/
modules/ system/ tests/ src/ Functional/ Session/ LegacySessionTest.php, line 30
Class
- LegacySessionTest
- Drupal legacy session handling tests.
Namespace
Drupal\Tests\system\Functional\SessionCode
public function testLegacyDataPersistence() : void {
$this->expectDeprecation('Storing values directly in $_SESSION is deprecated in drupal:11.2.0 and will become unsupported in drupal:12.0.0. Use $request->getSession()->set() instead. Affected keys: legacy_test_value. See https://www.drupal.org/node/3518527');
$value = $this->randomMachineName();
// Verify that the session value is stored.
$this->drupalGet('session-test/legacy-set/' . $value);
$this->assertSession()
->pageTextContains($value);
// Verify that the session correctly returned the stored data for an
// authenticated user.
$this->drupalGet('session-test/legacy-get');
$this->assertSession()
->pageTextContains($value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.