@@ -138,6 +138,69 @@ public function testOnCoreSecurity()
138
138
$ listener ->handle ($ event );
139
139
}
140
140
141
+ public function testSessionStrategy ()
142
+ {
143
+ list ($ listener , $ tokenStorage , $ service , $ manager ) = $ this ->getListener (false , true , true );
144
+
145
+ $ tokenStorage
146
+ ->expects ($ this ->once ())
147
+ ->method ('getToken ' )
148
+ ->will ($ this ->returnValue (null ))
149
+ ;
150
+
151
+ $ token = $ this ->getMock ('Symfony\Component\Security\Core\Authentication\Token\TokenInterface ' );
152
+ $ service
153
+ ->expects ($ this ->once ())
154
+ ->method ('autoLogin ' )
155
+ ->will ($ this ->returnValue ($ token ))
156
+ ;
157
+
158
+ $ tokenStorage
159
+ ->expects ($ this ->once ())
160
+ ->method ('setToken ' )
161
+ ->with ($ this ->equalTo ($ token ))
162
+ ;
163
+
164
+ $ manager
165
+ ->expects ($ this ->once ())
166
+ ->method ('authenticate ' )
167
+ ->will ($ this ->returnValue ($ token ))
168
+ ;
169
+
170
+ $ session = $ this ->getMock ('\Symfony\Component\HttpFoundation\Session\SessionInterface ' );
171
+ $ session
172
+ ->expects ($ this ->once ())
173
+ ->method ('isStarted ' )
174
+ ->will ($ this ->returnValue (true ))
175
+ ;
176
+ $ session
177
+ ->expects ($ this ->once ())
178
+ ->method ('migrate ' )
179
+ ;
180
+
181
+ $ request = $ this ->getMock ('\Symfony\Component\HttpFoundation\Request ' );
182
+ $ request
183
+ ->expects ($ this ->any ())
184
+ ->method ('hasSession ' )
185
+ ->will ($ this ->returnValue (true ))
186
+ ;
187
+
188
+ $ request
189
+ ->expects ($ this ->any ())
190
+ ->method ('getSession ' )
191
+ ->will ($ this ->returnValue ($ session ))
192
+ ;
193
+
194
+ $ event = $ this ->getGetResponseEvent ();
195
+ $ event
196
+ ->expects ($ this ->once ())
197
+ ->method ('getRequest ' )
198
+ ->will ($ this ->returnValue ($ request ))
199
+ ;
200
+
201
+ $ listener ->handle ($ event );
202
+ }
203
+
141
204
protected function getGetResponseEvent ()
142
205
{
143
206
return $ this ->getMock ('Symfony\Component\HttpKernel\Event\GetResponseEvent ' , array (), array (), '' , false );
0 commit comments