1010
1111class ResponseCookiesTest extends TestCase
1212{
13- /**
14- * @test
15- */
16- public function it_gets_cookies () : void
13+ public function testGet () : void
1714 {
1815 $ response = (new Response ());
1916
@@ -23,16 +20,46 @@ public function it_gets_cookies() : void
2320 ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('hello ' , 'world ' ))
2421 ;
2522
26- self :: assertEquals (
23+ $ this -> assertEquals (
2724 'ENCRYPTED ' ,
2825 ResponseCookies::get ($ response , 'sessionToken ' )->getValue ()
2926 );
3027 }
3128
32- /**
33- * @test
34- */
35- public function it_sets_cookies () : void
29+ public function testGetNull () : void
30+ {
31+ $ response = (new Response ());
32+
33+ $ response = $ response
34+ ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('theme ' , 'light ' ))
35+ ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('hello ' , 'world ' ))
36+ ;
37+
38+ $ this ->assertEquals (
39+ 'ENCRYPTED ' ,
40+ ResponseCookies::get ($ response , 'sessionToken ' , 'ENCRYPTED ' )->getValue ()
41+ );
42+ }
43+
44+ public function testExpire () : void
45+ {
46+ $ response = (new Response ());
47+
48+ $ response = $ response
49+ ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('theme ' , 'light ' ))
50+ ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('sessionToken ' , 'ENCRYPTED ' ))
51+ ->withAddedHeader (SetCookies::SET_COOKIE_HEADER , SetCookie::create ('hello ' , 'world ' ))
52+ ;
53+
54+ $ response = ResponseCookies::expire ($ response , 'sessionToken ' );
55+
56+ $ this ->assertEquals (
57+ '' ,
58+ ResponseCookies::get ($ response , 'sessionToken ' )->getValue ()
59+ );
60+ }
61+
62+ public function testSet () : void
3663 {
3764 $ response = (new Response ());
3865
@@ -44,16 +71,13 @@ public function it_sets_cookies() : void
4471
4572 $ response = ResponseCookies::set ($ response , SetCookie::create ('hello ' , 'WORLD! ' ));
4673
47- self :: assertEquals (
74+ $ this -> assertEquals (
4875 'theme=light,sessionToken=ENCRYPTED,hello=WORLD%21 ' ,
4976 $ response ->getHeaderLine ('Set-Cookie ' )
5077 );
5178 }
5279
53- /**
54- * @test
55- */
56- public function it_modifies_cookies () : void
80+ public function testModify () : void
5781 {
5882 $ response = (new Response ());
5983
@@ -67,16 +91,13 @@ public function it_modifies_cookies() : void
6791 return $ setCookie ->withValue (strtoupper ($ setCookie ->getName ()));
6892 });
6993
70- self :: assertEquals (
94+ $ this -> assertEquals (
7195 'theme=light,sessionToken=ENCRYPTED,hello=HELLO ' ,
7296 $ response ->getHeaderLine ('Set-Cookie ' )
7397 );
7498 }
7599
76- /**
77- * @test
78- */
79- public function it_removes_cookies () : void
100+ public function testRemove () : void
80101 {
81102 $ response = (new Response ());
82103
@@ -88,7 +109,7 @@ public function it_removes_cookies() : void
88109
89110 $ response = ResponseCookies::remove ($ response , 'sessionToken ' );
90111
91- self :: assertEquals (
112+ $ this -> assertEquals (
92113 'theme=light,hello=world ' ,
93114 $ response ->getHeaderLine ('Set-Cookie ' )
94115 );
0 commit comments