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());
90 * @runInSeparateProcess
91 * @preserveGlobalState disabled
93 public function testIsActive()
95 $this->assertFalse($this->proxy->isActive());
97 $this->assertTrue($this->proxy->isActive());
101 * @runInSeparateProcess
102 * @preserveGlobalState disabled
104 public function testName()
106 $this->assertEquals(session_name(), $this->proxy->getName());
107 $this->proxy->setName('foo');
108 $this->assertEquals('foo', $this->proxy->getName());
109 $this->assertEquals(session_name(), $this->proxy->getName());
113 * @runInSeparateProcess
114 * @preserveGlobalState disabled
115 * @expectedException \LogicException
117 public function testNameException()
120 $this->proxy->setName('foo');
124 * @runInSeparateProcess
125 * @preserveGlobalState disabled
127 public function testId()
129 $this->assertEquals(session_id(), $this->proxy->getId());
130 $this->proxy->setId('foo');
131 $this->assertEquals('foo', $this->proxy->getId());
132 $this->assertEquals(session_id(), $this->proxy->getId());
136 * @runInSeparateProcess
137 * @preserveGlobalState disabled
138 * @expectedException \LogicException
140 public function testIdException()
143 $this->proxy->setId('foo');