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 testOpenTrue()
51 $this->mock->expects($this->once())
53 ->will($this->returnValue(true));
55 $this->assertFalse($this->proxy->isActive());
56 $this->proxy->open('name', 'id');
57 $this->assertFalse($this->proxy->isActive());
60 public function testOpenFalse()
62 $this->mock->expects($this->once())
64 ->will($this->returnValue(false));
66 $this->assertFalse($this->proxy->isActive());
67 $this->proxy->open('name', 'id');
68 $this->assertFalse($this->proxy->isActive());
71 public function testClose()
73 $this->mock->expects($this->once())
75 ->will($this->returnValue(true));
77 $this->assertFalse($this->proxy->isActive());
78 $this->proxy->close();
79 $this->assertFalse($this->proxy->isActive());
82 public function testCloseFalse()
84 $this->mock->expects($this->once())
86 ->will($this->returnValue(false));
88 $this->assertFalse($this->proxy->isActive());
89 $this->proxy->close();
90 $this->assertFalse($this->proxy->isActive());
93 public function testRead()
95 $this->mock->expects($this->once())
98 $this->proxy->read('id');
101 public function testWrite()
103 $this->mock->expects($this->once())
106 $this->proxy->write('id', 'data');
109 public function testDestroy()
111 $this->mock->expects($this->once())
114 $this->proxy->destroy('id');
117 public function testGc()
119 $this->mock->expects($this->once())
122 $this->proxy->gc(86400);