Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / http-foundation / Tests / Session / Storage / Proxy / 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
12 namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Proxy;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
16
17 /**
18  * Tests for SessionHandlerProxy class.
19  *
20  * @author Drak <drak@zikula.org>
21  *
22  * @runTestsInSeparateProcesses
23  * @preserveGlobalState disabled
24  */
25 class SessionHandlerProxyTest extends TestCase
26 {
27     /**
28      * @var \PHPUnit_Framework_MockObject_Matcher
29      */
30     private $mock;
31
32     /**
33      * @var SessionHandlerProxy
34      */
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 }