You are here

public function PhpBridgeSessionStorageTest::testPhpSession54 in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php \Symfony\Component\HttpFoundation\Tests\Session\Storage\PhpBridgeSessionStorageTest::testPhpSession54()

File

vendor/symfony/http-foundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php, line 86

Class

PhpBridgeSessionStorageTest
Test class for PhpSessionStorage.

Namespace

Symfony\Component\HttpFoundation\Tests\Session\Storage

Code

public function testPhpSession54() {
  if (PHP_VERSION_ID < 50400) {
    $this
      ->markTestSkipped('Test skipped, for PHP 5.4 only.');
  }
  $storage = $this
    ->getStorage();
  $this
    ->assertFalse($storage
    ->getSaveHandler()
    ->isActive());
  $this
    ->assertFalse($storage
    ->isStarted());
  session_start();
  $this
    ->assertTrue(isset($_SESSION));

  // in PHP 5.4 we can reliably detect a session started
  $this
    ->assertTrue($storage
    ->getSaveHandler()
    ->isActive());

  // PHP session might have started, but the storage driver has not, so false is correct here
  $this
    ->assertFalse($storage
    ->isStarted());
  $key = $storage
    ->getMetadataBag()
    ->getStorageKey();
  $this
    ->assertFalse(isset($_SESSION[$key]));
  $storage
    ->start();
  $this
    ->assertTrue(isset($_SESSION[$key]));
}