14 use PHPUnit\Framework\TestCase;
36 protected function setUp()
38 $this->sessionDir = sys_get_temp_dir().
'/sf2test';
39 $this->storage = $this->getStorage();
44 $this->sessionDir =
null;
45 $this->storage =
null;
46 array_map(
'unlink', glob($this->sessionDir.
'/*.session'));
47 if (is_dir($this->sessionDir)) {
48 rmdir($this->sessionDir);
54 $this->assertEquals(
'', $this->storage->getId());
55 $this->assertTrue($this->storage->start());
56 $id = $this->storage->getId();
57 $this->assertNotEquals(
'', $this->storage->getId());
58 $this->assertTrue($this->storage->start());
59 $this->assertEquals($id, $this->storage->getId());
64 $this->storage->start();
65 $this->storage->getBag(
'attributes')->set(
'regenerate', 1234);
66 $this->storage->regenerate();
67 $this->assertEquals(1234, $this->storage->getBag(
'attributes')->get(
'regenerate'));
68 $this->storage->regenerate(
true);
69 $this->assertEquals(1234, $this->storage->getBag(
'attributes')->get(
'regenerate'));
74 $this->assertEquals(
'', $this->storage->getId());
75 $this->storage->start();
76 $this->assertNotEquals(
'', $this->storage->getId());
81 $this->storage->start();
82 $id = $this->storage->getId();
83 $this->assertNotEquals(
'108', $this->storage->getBag(
'attributes')->get(
'new'));
84 $this->assertFalse($this->storage->getBag(
'flashes')->has(
'newkey'));
85 $this->storage->getBag(
'attributes')->set(
'new',
'108');
86 $this->storage->getBag(
'flashes')->set(
'newkey',
'test');
87 $this->storage->save();
92 $this->assertEquals(
'108',
$storage->getBag(
'attributes')->get(
'new'));
93 $this->assertTrue(
$storage->getBag(
'flashes')->has(
'newkey'));
94 $this->assertEquals(array(
'test'),
$storage->getBag(
'flashes')->peek(
'newkey'));
99 $storage1 = $this->getStorage();
101 $storage1->getBag(
'attributes')->set(
'foo',
'bar');
104 $storage2 = $this->getStorage();
105 $storage2->setId($storage1->getId());
107 $this->assertEquals(
'bar', $storage2->getBag(
'attributes')->get(
'foo'),
'values persist between instances');
115 $storage1 = $this->getStorage();
119 private function getStorage()