@@ -28,7 +28,13 @@ protected function setUp()
28
28
$ this ->dualHandler = new MigratingSessionHandler ($ this ->currentHandler , $ this ->writeOnlyHandler );
29
29
}
30
30
31
- public function testCloses ()
31
+ public function testInstanceOf ()
32
+ {
33
+ $ this ->assertInstanceOf (\SessionHandlerInterface::class, $ this ->dualHandler );
34
+ $ this ->assertInstanceOf (\SessionUpdateTimestampHandlerInterface::class, $ this ->dualHandler );
35
+ }
36
+
37
+ public function testClose ()
32
38
{
33
39
$ this ->currentHandler ->expects ($ this ->once ())
34
40
->method ('close ' )
@@ -43,7 +49,7 @@ public function testCloses()
43
49
$ this ->assertTrue ($ result );
44
50
}
45
51
46
- public function testDestroys ()
52
+ public function testDestroy ()
47
53
{
48
54
$ sessionId = 'xyz ' ;
49
55
@@ -80,27 +86,27 @@ public function testGc()
80
86
$ this ->assertTrue ($ result );
81
87
}
82
88
83
- public function testOpens ()
89
+ public function testOpen ()
84
90
{
85
91
$ savePath = '/path/to/save/location ' ;
86
- $ sessionId = 'xyz ' ;
92
+ $ sessionName = 'xyz ' ;
87
93
88
94
$ this ->currentHandler ->expects ($ this ->once ())
89
95
->method ('open ' )
90
- ->with ($ savePath , $ sessionId )
96
+ ->with ($ savePath , $ sessionName )
91
97
->will ($ this ->returnValue (true ));
92
98
93
99
$ this ->writeOnlyHandler ->expects ($ this ->once ())
94
100
->method ('open ' )
95
- ->with ($ savePath , $ sessionId )
101
+ ->with ($ savePath , $ sessionName )
96
102
->will ($ this ->returnValue (false ));
97
103
98
- $ result = $ this ->dualHandler ->open ($ savePath , $ sessionId );
104
+ $ result = $ this ->dualHandler ->open ($ savePath , $ sessionName );
99
105
100
106
$ this ->assertTrue ($ result );
101
107
}
102
108
103
- public function testReads ()
109
+ public function testRead ()
104
110
{
105
111
$ sessionId = 'xyz ' ;
106
112
$ readValue = 'something ' ;
@@ -116,10 +122,10 @@ public function testReads()
116
122
117
123
$ result = $ this ->dualHandler ->read ($ sessionId );
118
124
119
- $ this ->assertEquals ($ readValue , $ result );
125
+ $ this ->assertSame ($ readValue , $ result );
120
126
}
121
127
122
- public function testWrites ()
128
+ public function testWrite ()
123
129
{
124
130
$ sessionId = 'xyz ' ;
125
131
$ data = 'my-serialized-data ' ;
@@ -138,4 +144,43 @@ public function testWrites()
138
144
139
145
$ this ->assertTrue ($ result );
140
146
}
147
+
148
+ public function testValidateId ()
149
+ {
150
+ $ sessionId = 'xyz ' ;
151
+ $ readValue = 'something ' ;
152
+
153
+ $ this ->currentHandler ->expects ($ this ->once ())
154
+ ->method ('read ' )
155
+ ->with ($ sessionId )
156
+ ->will ($ this ->returnValue ($ readValue ));
157
+
158
+ $ this ->writeOnlyHandler ->expects ($ this ->never ())
159
+ ->method ('read ' )
160
+ ->with ($ this ->any ());
161
+
162
+ $ result = $ this ->dualHandler ->validateId ($ sessionId );
163
+
164
+ $ this ->assertTrue ($ result );
165
+ }
166
+
167
+ public function testUpdateTimestamp ()
168
+ {
169
+ $ sessionId = 'xyz ' ;
170
+ $ data = 'my-serialized-data ' ;
171
+
172
+ $ this ->currentHandler ->expects ($ this ->once ())
173
+ ->method ('write ' )
174
+ ->with ($ sessionId , $ data )
175
+ ->will ($ this ->returnValue (true ));
176
+
177
+ $ this ->writeOnlyHandler ->expects ($ this ->once ())
178
+ ->method ('write ' )
179
+ ->with ($ sessionId , $ data )
180
+ ->will ($ this ->returnValue (false ));
181
+
182
+ $ result = $ this ->dualHandler ->updateTimestamp ($ sessionId , $ data );
183
+
184
+ $ this ->assertTrue ($ result );
185
+ }
141
186
}
0 commit comments