Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\HttpFoundation\Tests\Session\Storage;
 13: 
 14: use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
 15: use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag;
 16: 
 17: /**
 18:  * Test class for PhpSessionStorage.
 19:  *
 20:  * @author Drak <drak@zikula.org>
 21:  *
 22:  * These tests require separate processes.
 23:  *
 24:  * @runTestsInSeparateProcesses
 25:  * @preserveGlobalState disabled
 26:  */
 27: class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase
 28: {
 29:     private $savePath;
 30: 
 31:     protected function setUp()
 32:     {
 33:         $this->iniSet('session.save_handler', 'files');
 34:         $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test');
 35:         if (!is_dir($this->savePath)) {
 36:             mkdir($this->savePath);
 37:         }
 38:     }
 39: 
 40:     protected function tearDown()
 41:     {
 42:         session_write_close();
 43:         array_map('unlink', glob($this->savePath.'/*'));
 44:         if (is_dir($this->savePath)) {
 45:             rmdir($this->savePath);
 46:         }
 47: 
 48:         $this->savePath = null;
 49:     }
 50: 
 51:     /**
 52:      * @return PhpBridgeSessionStorage
 53:      */
 54:     protected function getStorage()
 55:     {
 56:         $storage = new PhpBridgeSessionStorage();
 57:         $storage->registerBag(new AttributeBag());
 58: 
 59:         return $storage;
 60:     }
 61: 
 62:     public function testPhpSession53()
 63:     {
 64:         if (PHP_VERSION_ID >= 50400) {
 65:             $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
 66:         }
 67: 
 68:         $storage = $this->getStorage();
 69: 
 70:         $this->assertFalse(isset($_SESSION));
 71:         $this->assertFalse($storage->getSaveHandler()->isActive());
 72: 
 73:         session_start();
 74:         $this->assertTrue(isset($_SESSION));
 75:         // in PHP 5.3 we cannot reliably tell if a session has started
 76:         $this->assertFalse($storage->getSaveHandler()->isActive());
 77:         // PHP session might have started, but the storage driver has not, so false is correct here
 78:         $this->assertFalse($storage->isStarted());
 79: 
 80:         $key = $storage->getMetadataBag()->getStorageKey();
 81:         $this->assertFalse(isset($_SESSION[$key]));
 82:         $storage->start();
 83:         $this->assertTrue(isset($_SESSION[$key]));
 84:     }
 85: 
 86:     public function testPhpSession54()
 87:     {
 88:         if (PHP_VERSION_ID < 50400) {
 89:             $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
 90:         }
 91: 
 92:         $storage = $this->getStorage();
 93: 
 94:         $this->assertFalse(isset($_SESSION));
 95:         $this->assertFalse($storage->getSaveHandler()->isActive());
 96:         $this->assertFalse($storage->isStarted());
 97: 
 98:         session_start();
 99:         $this->assertTrue(isset($_SESSION));
100:         // in PHP 5.4 we can reliably detect a session started
101:         $this->assertTrue($storage->getSaveHandler()->isActive());
102:         // PHP session might have started, but the storage driver has not, so false is correct here
103:         $this->assertFalse($storage->isStarted());
104: 
105:         $key = $storage->getMetadataBag()->getStorageKey();
106:         $this->assertFalse(isset($_SESSION[$key]));
107:         $storage->start();
108:         $this->assertTrue(isset($_SESSION[$key]));
109:     }
110: 
111:     public function testClear()
112:     {
113:         $storage = $this->getStorage();
114:         session_start();
115:         $_SESSION['drak'] = 'loves symfony';
116:         $storage->getBag('attributes')->set('symfony', 'greatness');
117:         $key = $storage->getBag('attributes')->getStorageKey();
118:         $this->assertEquals($_SESSION[$key], array('symfony' => 'greatness'));
119:         $this->assertEquals($_SESSION['drak'], 'loves symfony');
120:         $storage->clear();
121:         $this->assertEquals($_SESSION[$key], array());
122:         $this->assertEquals($_SESSION['drak'], 'loves symfony');
123:     }
124: }
125: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen