Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HttpFoundation] fixed FilesystemSessionStorage
- Loading branch information
1 parent
fd1636b
commit 30511d2
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/Symfony/Tests/Component/HttpFoundation/SessionStorage/FilesystemSessionStorageTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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\Tests\Component\HttpFoundation\SessionStorage; | ||
|
||
use Symfony\Component\HttpFoundation\SessionStorage\FilesystemSessionStorage; | ||
|
||
class FilesystemSessionStorageTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
private $path; | ||
|
||
protected function setUp() | ||
{ | ||
$this->path = sys_get_temp_dir().'/sf2/session_test'; | ||
if (!file_exists($this->path)) { | ||
mkdir($this->path, 0777, true); | ||
} | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
array_map('unlink', glob($this->path.'/*.session')); | ||
rmdir($this->path); | ||
} | ||
|
||
public function testMultipleInstances() | ||
{ | ||
$storage = new FilesystemSessionStorage($this->path); | ||
$storage->start(); | ||
$storage->write('foo', 'bar'); | ||
|
||
$storage = new FilesystemSessionStorage($this->path); | ||
$storage->start(); | ||
$this->assertEquals('bar', $storage->read('foo'), 'values persist between instances'); | ||
} | ||
|
||
public function testGetIdThrowsErrorBeforeStart() | ||
{ | ||
$this->setExpectedException('RuntimeException'); | ||
|
||
$storage = new FilesystemSessionStorage($this->path); | ||
$storage->getId(); | ||
} | ||
|
||
public function testGetIdWorksAfterStart() | ||
{ | ||
$storage = new FilesystemSessionStorage($this->path); | ||
$storage->start(); | ||
$storage->getId(); | ||
} | ||
} |