@@ -39,11 +39,10 @@ public function test_forbidden_if_protected_with_access_code_and_send_bad()
3939
4040 $ magiclink ->protectWithAccessCode ('1234 ' );
4141
42- $ response = $ this ->get ("{$ magiclink ->url }?access-code=123 " )
42+ $ this ->get ("{$ magiclink ->url }?access-code=123 " )
4343 ->assertStatus (403 )
44- ->assertViewIs ('magiclink::ask-for-access-code-form ' );
45-
46- $ this ->assertEquals (0 , count ($ response ->headers ->getCookies ()));
44+ ->assertViewIs ('magiclink::ask-for-access-code-form ' )
45+ ->assertCookieMissing ('magic-link-access-code ' );
4746 }
4847
4948 public function test_forbidden_if_protected_with_access_code_and_send_null ()
@@ -54,11 +53,10 @@ public function test_forbidden_if_protected_with_access_code_and_send_null()
5453
5554 $ magiclink ->protectWithAccessCode ('1234 ' );
5655
57- $ response = $ this ->get ("{$ magiclink ->url }" )
56+ $ this ->get ("{$ magiclink ->url }" )
5857 ->assertStatus (403 )
59- ->assertViewIs ('magiclink::ask-for-access-code-form ' );
60-
61- $ this ->assertEquals (0 , count ($ response ->headers ->getCookies ()));
58+ ->assertViewIs ('magiclink::ask-for-access-code-form ' )
59+ ->assertCookieMissing ('magic-link-access-code ' );
6260 }
6361
6462 public function test_sucessfull_if_provide_access_code ()
@@ -70,10 +68,12 @@ public function test_sucessfull_if_provide_access_code()
7068 $ magiclink ->protectWithAccessCode ('1234 ' );
7169
7270 $ response = $ this ->get ("{$ magiclink ->url }?access-code=1234 " )
71+ ->assertCookie ('magic-link-access-code ' )
7372 ->assertStatus (302 )
7473 ->assertRedirect ($ magiclink ->url );
7574
76- $ cookie = $ response ->headers ->getCookies ()[0 ];
75+ $ cookie = collect ($ response ->headers ->getCookies ())
76+ ->first (fn ($ cookie ) => $ cookie ->getName () === 'magic-link-access-code ' );
7777
7878 $ this ->disableCookieEncryption ()->withCookie ($ cookie ->getName (), $ cookie ->getvalue ())
7979 ->get ($ magiclink ->url )
@@ -91,7 +91,8 @@ public function test_forbidden_if_provide_access_code_of_other_link()
9191
9292 $ response = $ this ->get ("{$ magiclink ->url }?access-code=1234 " );
9393
94- $ cookie = $ response ->headers ->getCookies ()[0 ];
94+ $ cookie = collect ($ response ->headers ->getCookies ())
95+ ->first (fn ($ cookie ) => $ cookie ->getName () === 'magic-link-access-code ' );
9596
9697 $ magiclinkOther = MagicLink::create (new ResponseAction (function () {
9798 return 'the other big secret ' ;
0 commit comments