@@ -27,26 +27,25 @@ public function getResolutionTests()
2727 $ tests [] = array (Request::create ('/?hl=de ' ), array ('foo ' ), 'de ' , 'Query parameter is selected ' );
2828 $ tests [] = array (Request::create ('/?hl=de ' , 'GET ' , array (), array ('hl ' => 'en ' )), array ('foo ' ), 'de ' , 'Query parameter has precedence before cookie ' );
2929
30- $ session = $ this ->getMock ('Symfony\Component\HttpFoundation\Session\SessionInterface ' );
31- $ session ->expects ($ this ->any ())
32- ->method ('has ' )
33- ->with ('_locale ' )
34- ->will ($ this ->returnValue (true ));
35- $ session ->expects ($ this ->any ())
36- ->method ('get ' )
37- ->with ('_locale ' )
38- ->will ($ this ->returnValue ('fr ' ));
39- $ session ->expects ($ this ->any ())
40- ->method ('getName ' )
41- ->will ($ this ->returnValue ('SESS ' ));
42-
4330 $ tests [] = array ($ request = Request::create ('/?hl=de ' , 'GET ' , array (), array ('SESS ' => 'foo ' )), array ('foo ' ), 'de ' , 'Query parameter has precedence before session ' );
31+ $ session = $ this ->createSession ();
4432 $ request ->setSession ($ session );
4533
4634 $ tests [] = array ($ request = Request::create ('/ ' , 'GET ' , array (), array ('SESS ' => 'foo ' )), array ('foo ' ), 'fr ' , 'Session is used ' );
35+ $ session = $ this ->createSession ();
36+ $ request ->setSession ($ session );
37+
38+ $ tests [] = array ($ request = Request::create ('/ ' , 'GET ' , array (), array ('SESS ' => 'foo ' )), array ('foo ' ), null , 'No session ' );
39+
40+ $ tests [] = array ($ request = Request::create ('/ ' , 'GET ' , array (), array ('SESS ' => 'foo ' )), array ('foo ' ), 'fr ' , 'Session is not started ' );
41+ $ session = $ this ->createSession ();
42+ $ session ->expects ($ this ->any ())
43+ ->method ('isStarted ' )
44+ ->will ($ this ->returnValue (false ));
4745 $ request ->setSession ($ session );
4846
4947 $ tests [] = array ($ request = Request::create ('/ ' , 'GET ' , array (), array ('hl ' => 'es ' , 'SESS ' => 'foo ' )), array ('foo ' ), 'fr ' , 'Session has precedence before cookie. ' );
48+ $ session = $ this ->createSession ();
5049 $ request ->setSession ($ session );
5150
5251 $ tests [] = array (Request::create ('/ ' , 'GET ' , array (), array ('hl ' => 'es ' )), array ('foo ' ), 'es ' , 'Cookie is used ' );
@@ -65,4 +64,25 @@ protected function setUp()
6564 'bar ' => 'de ' ,
6665 ));
6766 }
68- }
67+
68+ private function createSession ()
69+ {
70+ $ session = $ this ->getMock ('Symfony\Component\HttpFoundation\Session\SessionInterface ' );
71+ $ session ->expects ($ this ->any ())
72+ ->method ('has ' )
73+ ->with ('_locale ' )
74+ ->will ($ this ->returnValue (true ));
75+ $ session ->expects ($ this ->any ())
76+ ->method ('get ' )
77+ ->with ('_locale ' )
78+ ->will ($ this ->returnValue ('fr ' ));
79+ $ session ->expects ($ this ->any ())
80+ ->method ('getName ' )
81+ ->will ($ this ->returnValue ('SESS ' ));
82+ $ session ->expects ($ this ->any ())
83+ ->method ('isStarted ' )
84+ ->will ($ this ->returnValue (true ));
85+
86+ return $ session ;
87+ }
88+ }
0 commit comments