Server IP : 127.0.0.2 / Your IP : 3.144.112.72 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/symfony/http-foundation/Tests/Session/Storage/ |
Upload File : |
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; /** * Test class for PhpSessionStorage. * * @author Drak <drak@zikula.org> * * These tests require separate processes. * * @runTestsInSeparateProcesses * @preserveGlobalState disabled */ class PhpBridgeSessionStorageTest extends \PHPUnit_Framework_TestCase { private $savePath; protected function setUp() { $this->iniSet('session.save_handler', 'files'); $this->iniSet('session.save_path', $this->savePath = sys_get_temp_dir().'/sf2test'); if (!is_dir($this->savePath)) { mkdir($this->savePath); } } protected function tearDown() { session_write_close(); array_map('unlink', glob($this->savePath.'/*')); if (is_dir($this->savePath)) { rmdir($this->savePath); } $this->savePath = null; } /** * @return PhpBridgeSessionStorage */ protected function getStorage() { $storage = new PhpBridgeSessionStorage(); $storage->registerBag(new AttributeBag()); return $storage; } public function testPhpSession() { $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])); } public function testClear() { $storage = $this->getStorage(); session_start(); $_SESSION['drak'] = 'loves symfony'; $storage->getBag('attributes')->set('symfony', 'greatness'); $key = $storage->getBag('attributes')->getStorageKey(); $this->assertEquals($_SESSION[$key], array('symfony' => 'greatness')); $this->assertEquals($_SESSION['drak'], 'loves symfony'); $storage->clear(); $this->assertEquals($_SESSION[$key], array()); $this->assertEquals($_SESSION['drak'], 'loves symfony'); } }