1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy;
13:
14: use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
15:
16: 17: 18: 19: 20: 21: 22: 23:
24: class SessionHandlerProxyTest extends \PHPUnit_Framework_TestCase
25: {
26: 27: 28:
29: private $mock;
30:
31: 32: 33:
34: private $proxy;
35:
36: protected function setUp()
37: {
38: $this->mock = $this->getMock('SessionHandlerInterface');
39: $this->proxy = new SessionHandlerProxy($this->mock);
40: }
41:
42: protected function tearDown()
43: {
44: $this->mock = null;
45: $this->proxy = null;
46: }
47:
48: public function testOpen()
49: {
50: $this->mock->expects($this->once())
51: ->method('open')
52: ->will($this->returnValue(true));
53:
54: $this->assertFalse($this->proxy->isActive());
55: $this->proxy->open('name', 'id');
56: if (PHP_VERSION_ID < 50400) {
57: $this->assertTrue($this->proxy->isActive());
58: } else {
59: $this->assertFalse($this->proxy->isActive());
60: }
61: }
62:
63: public function testOpenFalse()
64: {
65: $this->mock->expects($this->once())
66: ->method('open')
67: ->will($this->returnValue(false));
68:
69: $this->assertFalse($this->proxy->isActive());
70: $this->proxy->open('name', 'id');
71: $this->assertFalse($this->proxy->isActive());
72: }
73:
74: public function testClose()
75: {
76: $this->mock->expects($this->once())
77: ->method('close')
78: ->will($this->returnValue(true));
79:
80: $this->assertFalse($this->proxy->isActive());
81: $this->proxy->close();
82: $this->assertFalse($this->proxy->isActive());
83: }
84:
85: public function testCloseFalse()
86: {
87: $this->mock->expects($this->once())
88: ->method('close')
89: ->will($this->returnValue(false));
90:
91: $this->assertFalse($this->proxy->isActive());
92: $this->proxy->close();
93: $this->assertFalse($this->proxy->isActive());
94: }
95:
96: public function testRead()
97: {
98: $this->mock->expects($this->once())
99: ->method('read');
100:
101: $this->proxy->read('id');
102: }
103:
104: public function testWrite()
105: {
106: $this->mock->expects($this->once())
107: ->method('write');
108:
109: $this->proxy->write('id', 'data');
110: }
111:
112: public function testDestroy()
113: {
114: $this->mock->expects($this->once())
115: ->method('destroy');
116:
117: $this->proxy->destroy('id');
118: }
119:
120: public function testGc()
121: {
122: $this->mock->expects($this->once())
123: ->method('gc');
124:
125: $this->proxy->gc(86400);
126: }
127: }
128: