4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
17 // Note until PHPUnit_Mock_Objects 1.2 is released you cannot mock abstracts due to
18 // https://github.com/sebastianbergmann/phpunit-mock-objects/issues/73
19 class ConcreteProxy extends AbstractProxy
23 class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface
25 public function open($savePath, $sessionName)
29 public function close()
33 public function read($id)
37 public function write($id, $data)
41 public function destroy($id)
45 public function gc($maxlifetime)
51 * Test class for AbstractProxy.
53 * @author Drak <drak@zikula.org>
55 class AbstractProxyTest extends TestCase
62 protected function setUp()
64 $this->proxy = new ConcreteProxy();
67 protected function tearDown()
72 public function testGetSaveHandlerName()
74 $this->assertNull($this->proxy->getSaveHandlerName());
77 public function testIsSessionHandlerInterface()
79 $this->assertFalse($this->proxy->isSessionHandlerInterface());
80 $sh = new ConcreteSessionHandlerInterfaceProxy();
81 $this->assertTrue($sh->isSessionHandlerInterface());
84 public function testIsWrapper()
86 $this->assertFalse($this->proxy->isWrapper());
89 public function testIsActivePhp53()
91 if (\PHP_VERSION_ID >= 50400) {
92 $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
95 $this->assertFalse($this->proxy->isActive());
99 * @runInSeparateProcess
100 * @preserveGlobalState disabled
103 public function testIsActivePhp54()
105 $this->assertFalse($this->proxy->isActive());
107 $this->assertTrue($this->proxy->isActive());
110 public function testSetActivePhp53()
112 if (\PHP_VERSION_ID >= 50400) {
113 $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
116 $this->proxy->setActive(true);
117 $this->assertTrue($this->proxy->isActive());
118 $this->proxy->setActive(false);
119 $this->assertFalse($this->proxy->isActive());
123 * @runInSeparateProcess
124 * @preserveGlobalState disabled
125 * @expectedException \LogicException
128 public function testSetActivePhp54()
130 $this->proxy->setActive(true);
134 * @runInSeparateProcess
135 * @preserveGlobalState disabled
137 public function testName()
139 $this->assertEquals(session_name(), $this->proxy->getName());
140 $this->proxy->setName('foo');
141 $this->assertEquals('foo', $this->proxy->getName());
142 $this->assertEquals(session_name(), $this->proxy->getName());
146 * @expectedException \LogicException
148 public function testNameExceptionPhp53()
150 if (\PHP_VERSION_ID >= 50400) {
151 $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
154 $this->proxy->setActive(true);
155 $this->proxy->setName('foo');
159 * @runInSeparateProcess
160 * @preserveGlobalState disabled
161 * @expectedException \LogicException
164 public function testNameExceptionPhp54()
167 $this->proxy->setName('foo');
171 * @runInSeparateProcess
172 * @preserveGlobalState disabled
174 public function testId()
176 $this->assertEquals(session_id(), $this->proxy->getId());
177 $this->proxy->setId('foo');
178 $this->assertEquals('foo', $this->proxy->getId());
179 $this->assertEquals(session_id(), $this->proxy->getId());
183 * @expectedException \LogicException
185 public function testIdExceptionPhp53()
187 if (\PHP_VERSION_ID >= 50400) {
188 $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
191 $this->proxy->setActive(true);
192 $this->proxy->setId('foo');
196 * @runInSeparateProcess
197 * @preserveGlobalState disabled
198 * @expectedException \LogicException
201 public function testIdExceptionPhp54()
204 $this->proxy->setId('foo');