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\AbstractProxy;
15:
16:
17:
18: class ConcreteProxy extends AbstractProxy
19: {
20: }
21:
22: class ConcreteSessionHandlerInterfaceProxy extends AbstractProxy implements \SessionHandlerInterface
23: {
24: public function open($savePath, $sessionName)
25: {
26: }
27:
28: public function close()
29: {
30: }
31:
32: public function read($id)
33: {
34: }
35:
36: public function write($id, $data)
37: {
38: }
39:
40: public function destroy($id)
41: {
42: }
43:
44: public function gc($maxlifetime)
45: {
46: }
47: }
48:
49: 50: 51: 52: 53:
54: class AbstractProxyTest extends \PHPUnit_Framework_TestCase
55: {
56: 57: 58:
59: protected $proxy;
60:
61: protected function setUp()
62: {
63: $this->proxy = new ConcreteProxy();
64: }
65:
66: protected function tearDown()
67: {
68: $this->proxy = null;
69: }
70:
71: public function testGetSaveHandlerName()
72: {
73: $this->assertNull($this->proxy->getSaveHandlerName());
74: }
75:
76: public function testIsSessionHandlerInterface()
77: {
78: $this->assertFalse($this->proxy->isSessionHandlerInterface());
79: $sh = new ConcreteSessionHandlerInterfaceProxy();
80: $this->assertTrue($sh->isSessionHandlerInterface());
81: }
82:
83: public function testIsWrapper()
84: {
85: $this->assertFalse($this->proxy->isWrapper());
86: }
87:
88: public function testIsActivePhp53()
89: {
90: if (PHP_VERSION_ID >= 50400) {
91: $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
92: }
93:
94: $this->assertFalse($this->proxy->isActive());
95: }
96:
97: 98: 99: 100:
101: public function testIsActivePhp54()
102: {
103: if (PHP_VERSION_ID < 50400) {
104: $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
105: }
106:
107: $this->assertFalse($this->proxy->isActive());
108: session_start();
109: $this->assertTrue($this->proxy->isActive());
110: }
111:
112: public function testSetActivePhp53()
113: {
114: if (PHP_VERSION_ID >= 50400) {
115: $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
116: }
117:
118: $this->proxy->setActive(true);
119: $this->assertTrue($this->proxy->isActive());
120: $this->proxy->setActive(false);
121: $this->assertFalse($this->proxy->isActive());
122: }
123:
124: 125: 126: 127: 128:
129: public function testSetActivePhp54()
130: {
131: if (PHP_VERSION_ID < 50400) {
132: $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
133: }
134:
135: $this->proxy->setActive(true);
136: }
137:
138: 139: 140: 141:
142: public function testName()
143: {
144: $this->assertEquals(session_name(), $this->proxy->getName());
145: $this->proxy->setName('foo');
146: $this->assertEquals('foo', $this->proxy->getName());
147: $this->assertEquals(session_name(), $this->proxy->getName());
148: }
149:
150: 151: 152:
153: public function testNameExceptionPhp53()
154: {
155: if (PHP_VERSION_ID >= 50400) {
156: $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
157: }
158:
159: $this->proxy->setActive(true);
160: $this->proxy->setName('foo');
161: }
162:
163: 164: 165: 166: 167:
168: public function testNameExceptionPhp54()
169: {
170: if (PHP_VERSION_ID < 50400) {
171: $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
172: }
173:
174: session_start();
175: $this->proxy->setName('foo');
176: }
177:
178: 179: 180: 181:
182: public function testId()
183: {
184: $this->assertEquals(session_id(), $this->proxy->getId());
185: $this->proxy->setId('foo');
186: $this->assertEquals('foo', $this->proxy->getId());
187: $this->assertEquals(session_id(), $this->proxy->getId());
188: }
189:
190: 191: 192:
193: public function testIdExceptionPhp53()
194: {
195: if (PHP_VERSION_ID >= 50400) {
196: $this->markTestSkipped('Test skipped, for PHP 5.3 only.');
197: }
198:
199: $this->proxy->setActive(true);
200: $this->proxy->setId('foo');
201: }
202:
203: 204: 205: 206: 207:
208: public function testIdExceptionPhp54()
209: {
210: if (PHP_VERSION_ID < 50400) {
211: $this->markTestSkipped('Test skipped, for PHP 5.4 only.');
212: }
213:
214: session_start();
215: $this->proxy->setId('foo');
216: }
217: }
218: