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\SessionHandlerProxy;
18 * Tests for SessionHandlerProxy class.
20 * @author Drak <drak@zikula.org>
22 * @runTestsInSeparateProcesses
23 * @preserveGlobalState disabled
25 class SessionHandlerProxyTest extends TestCase
28 * @var \PHPUnit_Framework_MockObject_Matcher
33 * @var SessionHandlerProxy
37 protected function setUp()
39 $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
40 $this->proxy = new SessionHandlerProxy($this->mock);
43 protected function tearDown()
49 public function testOpen()
51 $this->mock->expects($this->once())
53 ->will($this->returnValue(true));
55 $this->assertFalse($this->proxy->isActive());
56 $this->proxy->open('name', 'id');
57 if (\PHP_VERSION_ID < 50400) {
58 $this->assertTrue($this->proxy->isActive());
60 $this->assertFalse($this->proxy->isActive());
64 public function testOpenFalse()
66 $this->mock->expects($this->once())
68 ->will($this->returnValue(false));
70 $this->assertFalse($this->proxy->isActive());
71 $this->proxy->open('name', 'id');
72 $this->assertFalse($this->proxy->isActive());
75 public function testClose()
77 $this->mock->expects($this->once())
79 ->will($this->returnValue(true));
81 $this->assertFalse($this->proxy->isActive());
82 $this->proxy->close();
83 $this->assertFalse($this->proxy->isActive());
86 public function testCloseFalse()
88 $this->mock->expects($this->once())
90 ->will($this->returnValue(false));
92 $this->assertFalse($this->proxy->isActive());
93 $this->proxy->close();
94 $this->assertFalse($this->proxy->isActive());
97 public function testRead()
99 $this->mock->expects($this->once())
102 $this->proxy->read('id');
105 public function testWrite()
107 $this->mock->expects($this->once())
110 $this->proxy->write('id', 'data');
113 public function testDestroy()
115 $this->mock->expects($this->once())
118 $this->proxy->destroy('id');
121 public function testGc()
123 $this->mock->expects($this->once())
126 $this->proxy->gc(86400);