You are here

public function NativeSessionStorageTest::testStartedOutside in Zircon Profile 8.0

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

@expectedException \RuntimeException

File

vendor/symfony/http-foundation/Tests/Session/Storage/NativeSessionStorageTest.php, line 226

Class

NativeSessionStorageTest
Test class for NativeSessionStorage.

Namespace

Symfony\Component\HttpFoundation\Tests\Session\Storage

Code

public function testStartedOutside() {
  $storage = $this
    ->getStorage();
  $this
    ->assertFalse($storage
    ->getSaveHandler()
    ->isActive());
  $this
    ->assertFalse($storage
    ->isStarted());
  session_start();
  $this
    ->assertTrue(isset($_SESSION));
  if (PHP_VERSION_ID >= 50400) {

    // this only works in PHP >= 5.4 where session_status is available
    $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();
}