File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 26
26
use Symfony \Component \Security \Core \Exception \AuthenticationException ;
27
27
use Symfony \Component \Security \Core \Security as DeprecatedSecurity ;
28
28
use Symfony \Component \Security \Http \Authentication \AuthenticationUtils ;
29
+ use Symfony \Component \Security \Http \SecurityRequestAttributes ;
29
30
use Twig \Environment ;
30
31
31
32
final class LoginControllerTest extends TestCase
@@ -211,6 +212,12 @@ private function createController(): LoginController
211
212
212
213
private function getSecurityErrorKey (): string
213
214
{
215
+ // Symfony 6.4+ compatibility
216
+ if (class_exists (SecurityRequestAttributes::class)) {
217
+ return SecurityRequestAttributes::AUTHENTICATION_ERROR ;
218
+ }
219
+
220
+ // Symfony 5.4 & <6.4 compatibility
214
221
return class_exists (Security::class) ? Security::AUTHENTICATION_ERROR : DeprecatedSecurity::AUTHENTICATION_ERROR ;
215
222
}
216
223
}
Original file line number Diff line number Diff line change 20
20
use Symfony \Component \HttpClient \MockHttpClient ;
21
21
use Symfony \Component \Security \Core \Exception \UserNotFoundException ;
22
22
use Symfony \Component \Security \Core \Security as DeprecatedSecurity ;
23
+ use Symfony \Component \Security \Http \SecurityRequestAttributes ;
23
24
use Symfony \Contracts \HttpClient \HttpClientInterface ;
24
25
25
26
final class LoginControllerTest extends WebTestCase
@@ -84,6 +85,12 @@ public function testLoginPageWithError(): void
84
85
85
86
private function getSecurityErrorKey (): string
86
87
{
88
+ // Symfony 6.4+ compatibility
89
+ if (class_exists (SecurityRequestAttributes::class)) {
90
+ return SecurityRequestAttributes::AUTHENTICATION_ERROR ;
91
+ }
92
+
93
+ // Symfony 5.4 & <6.4 compatibility
87
94
return class_exists (Security::class) ? Security::AUTHENTICATION_ERROR : DeprecatedSecurity::AUTHENTICATION_ERROR ;
88
95
}
89
96
}
You can’t perform that action at this time.
0 commit comments