12
12
namespace Symfony \Component \Security \Http \Tests \Logout ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \HttpFoundation \Cookie ;
15
16
use Symfony \Component \HttpFoundation \Request ;
16
17
use Symfony \Component \HttpFoundation \Response ;
17
18
use Symfony \Component \HttpFoundation \ResponseHeaderBag ;
@@ -25,7 +26,7 @@ public function testLogout()
25
26
$ response = new Response ();
26
27
$ token = $ this ->getMockBuilder ('Symfony\Component\Security\Core\Authentication\Token\TokenInterface ' )->getMock ();
27
28
28
- $ handler = new CookieClearingLogoutHandler (['foo ' => ['path ' => '/foo ' , 'domain ' => 'foo.foo ' ], 'foo2 ' => ['path ' => null , 'domain ' => null ]]);
29
+ $ handler = new CookieClearingLogoutHandler (['foo ' => ['path ' => '/foo ' , 'domain ' => 'foo.foo ' , ' secure ' => true , ' samesite ' => Cookie:: SAMESITE_STRICT ], 'foo2 ' => ['path ' => null , 'domain ' => null ]]);
29
30
30
31
$ cookies = $ response ->headers ->getCookies ();
31
32
$ this ->assertCount (0 , $ cookies );
@@ -39,12 +40,16 @@ public function testLogout()
39
40
$ this ->assertEquals ('foo ' , $ cookie ->getName ());
40
41
$ this ->assertEquals ('/foo ' , $ cookie ->getPath ());
41
42
$ this ->assertEquals ('foo.foo ' , $ cookie ->getDomain ());
43
+ $ this ->assertEquals (Cookie::SAMESITE_STRICT , $ cookie ->getSameSite ());
44
+ $ this ->assertTrue ($ cookie ->isSecure ());
42
45
$ this ->assertTrue ($ cookie ->isCleared ());
43
46
44
47
$ cookie = $ cookies ['' ]['/ ' ]['foo2 ' ];
45
48
$ this ->assertStringStartsWith ('foo2 ' , $ cookie ->getName ());
46
49
$ this ->assertEquals ('/ ' , $ cookie ->getPath ());
47
50
$ this ->assertNull ($ cookie ->getDomain ());
51
+ $ this ->assertNull ($ cookie ->getSameSite ());
52
+ $ this ->assertFalse ($ cookie ->isSecure ());
48
53
$ this ->assertTrue ($ cookie ->isCleared ());
49
54
}
50
55
}
0 commit comments