Open Monograph Press  3.3.0
SessionHandlerProxyTest.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
14 use PHPUnit\Framework\TestCase;
16 
25 class SessionHandlerProxyTest extends TestCase
26 {
30  private $mock;
31 
35  private $proxy;
36 
37  protected function setUp()
38  {
39  $this->mock = $this->getMockBuilder('SessionHandlerInterface')->getMock();
40  $this->proxy = new SessionHandlerProxy($this->mock);
41  }
42 
43  protected function tearDown()
44  {
45  $this->mock = null;
46  $this->proxy = null;
47  }
48 
49  public function testOpenTrue()
50  {
51  $this->mock->expects($this->once())
52  ->method('open')
53  ->will($this->returnValue(true));
54 
55  $this->assertFalse($this->proxy->isActive());
56  $this->proxy->open('name', 'id');
57  $this->assertFalse($this->proxy->isActive());
58  }
59 
60  public function testOpenFalse()
61  {
62  $this->mock->expects($this->once())
63  ->method('open')
64  ->will($this->returnValue(false));
65 
66  $this->assertFalse($this->proxy->isActive());
67  $this->proxy->open('name', 'id');
68  $this->assertFalse($this->proxy->isActive());
69  }
70 
71  public function testClose()
72  {
73  $this->mock->expects($this->once())
74  ->method('close')
75  ->will($this->returnValue(true));
76 
77  $this->assertFalse($this->proxy->isActive());
78  $this->proxy->close();
79  $this->assertFalse($this->proxy->isActive());
80  }
81 
82  public function testCloseFalse()
83  {
84  $this->mock->expects($this->once())
85  ->method('close')
86  ->will($this->returnValue(false));
87 
88  $this->assertFalse($this->proxy->isActive());
89  $this->proxy->close();
90  $this->assertFalse($this->proxy->isActive());
91  }
92 
93  public function testRead()
94  {
95  $this->mock->expects($this->once())
96  ->method('read');
97 
98  $this->proxy->read('id');
99  }
100 
101  public function testWrite()
102  {
103  $this->mock->expects($this->once())
104  ->method('write');
105 
106  $this->proxy->write('id', 'data');
107  }
108 
109  public function testDestroy()
110  {
111  $this->mock->expects($this->once())
112  ->method('destroy');
113 
114  $this->proxy->destroy('id');
115  }
116 
117  public function testGc()
118  {
119  $this->mock->expects($this->once())
120  ->method('gc');
121 
122  $this->proxy->gc(86400);
123  }
124 }
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testOpenFalse
testOpenFalse()
Definition: SessionHandlerProxyTest.php:66
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testCloseFalse
testCloseFalse()
Definition: SessionHandlerProxyTest.php:88
Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy
Definition: lib/vendor/symfony/http-foundation/Session/Storage/Proxy/SessionHandlerProxy.php:19
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testWrite
testWrite()
Definition: SessionHandlerProxyTest.php:107
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\tearDown
tearDown()
Definition: SessionHandlerProxyTest.php:49
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testClose
testClose()
Definition: SessionHandlerProxyTest.php:77
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy
Definition: AbstractProxyTest.php:12
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testDestroy
testDestroy()
Definition: SessionHandlerProxyTest.php:115
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testRead
testRead()
Definition: SessionHandlerProxyTest.php:99
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testOpenTrue
testOpenTrue()
Definition: SessionHandlerProxyTest.php:55
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\testGc
testGc()
Definition: SessionHandlerProxyTest.php:123
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest\setUp
setUp()
Definition: SessionHandlerProxyTest.php:43
Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy\SessionHandlerProxyTest
Definition: SessionHandlerProxyTest.php:25