2121
2222class TwoFactorAccessDeciderTest extends TestCase
2323{
24- private const BASE_URL = '/app_dev.php ' ;
25- private const LOGOUT_PATH = '/logout ' ;
26- private const LOGOUT_PATH_WITH_BASE_URL = self ::BASE_URL .self ::LOGOUT_PATH ;
2724 private const ACCESS_MAP_ATTRIBUTES = [TwoFactorInProgressVoter::IS_AUTHENTICATED_2FA_IN_PROGRESS ];
2825
2926 private MockObject |Request $ request ;
3027 private MockObject |TokenInterface $ token ;
3128 private MockObject |AccessMapInterface $ accessMap ;
3229 private MockObject |AccessDecisionManagerInterface $ accessDecisionManager ;
33- private MockObject |HttpUtils $ httpUtils ;
34- private MockObject |LogoutUrlGenerator $ logoutUrlGenerator ;
3530 private TwoFactorAccessDecider $ accessDecider ;
3631
3732 /** @var string[]|null */
@@ -43,9 +38,7 @@ protected function setUp(): void
4338 $ this ->token = $ this ->createMock (TokenInterface::class);
4439 $ this ->accessMap = $ this ->createMock (AccessMapInterface::class);
4540 $ this ->accessDecisionManager = $ this ->createMock (AccessDecisionManagerInterface::class);
46- $ this ->httpUtils = $ this ->createMock (HttpUtils::class);
47- $ this ->logoutUrlGenerator = $ this ->createMock (LogoutUrlGenerator::class);
48- $ this ->accessDecider = new TwoFactorAccessDecider ($ this ->accessMap , $ this ->accessDecisionManager , $ this ->httpUtils , $ this ->logoutUrlGenerator );
41+ $ this ->accessDecider = new TwoFactorAccessDecider ($ this ->accessMap , $ this ->accessDecisionManager );
4942 }
5043
5144 private function stubAccessMapReturnsAttributes (array |null $ attributes ): void
@@ -58,14 +51,6 @@ private function stubAccessMapReturnsAttributes(array|null $attributes): void
5851 ->willReturn ([$ attributes , 'https ' ]);
5952 }
6053
61- private function whenGeneratedLogoutPath (string $ generatedLogoutPath ): void
62- {
63- $ this ->logoutUrlGenerator
64- ->expects ($ this ->any ())
65- ->method ('getLogoutPath ' )
66- ->willReturn ($ generatedLogoutPath );
67- }
68-
6954 private function whenRequestBaseUrl (string $ baseUrl ): void
7055 {
7156 $ this ->request
@@ -83,15 +68,6 @@ private function whenPathAccess(bool $accessGranted): void
8368 ->willReturn ($ accessGranted );
8469 }
8570
86- private function whenIsLogoutPath (bool $ accessGranted ): void
87- {
88- $ this ->httpUtils
89- ->expects ($ this ->any ())
90- ->method ('checkRequestPath ' )
91- ->with ($ this ->request , self ::LOGOUT_PATH )
92- ->willReturn ($ accessGranted );
93- }
94-
9571 /**
9672 * @return iterable<string>
9773 */
@@ -134,7 +110,6 @@ public function isAccessible_pathAccessGranted_returnTrue(): void
134110 {
135111 $ this ->stubAccessMapReturnsAttributes (self ::ACCESS_MAP_ATTRIBUTES );
136112 $ this ->whenPathAccess (true );
137- $ this ->whenIsLogoutPath (false );
138113
139114 $ returnValue = $ this ->accessDecider ->isAccessible ($ this ->request , $ this ->token );
140115 $ this ->assertTrue ($ returnValue );
@@ -146,35 +121,7 @@ public function isAccessible_isPubliclyAccessible_returnTrue(string $publicAcces
146121 {
147122 $ this ->stubAccessMapReturnsAttributes ([$ publicAccessAttribute ]);
148123 $ this ->whenRequestBaseUrl ('' );
149- $ this ->whenGeneratedLogoutPath (self ::LOGOUT_PATH );
150- $ this ->whenPathAccess (false );
151- $ this ->whenIsLogoutPath (false );
152-
153- $ returnValue = $ this ->accessDecider ->isAccessible ($ this ->request , $ this ->token );
154- $ this ->assertTrue ($ returnValue );
155- }
156-
157- #[Test]
158- public function isAccessible_isLogoutPathNoBasePath_returnTrue (): void
159- {
160- $ this ->stubAccessMapReturnsAttributes (self ::ACCESS_MAP_ATTRIBUTES );
161- $ this ->whenRequestBaseUrl ('' );
162- $ this ->whenGeneratedLogoutPath (self ::LOGOUT_PATH );
163- $ this ->whenPathAccess (false );
164- $ this ->whenIsLogoutPath (true );
165-
166- $ returnValue = $ this ->accessDecider ->isAccessible ($ this ->request , $ this ->token );
167- $ this ->assertTrue ($ returnValue );
168- }
169-
170- #[Test]
171- public function isAccessible_isLogoutPathWithBasePath_returnTrue (): void
172- {
173- $ this ->stubAccessMapReturnsAttributes (self ::ACCESS_MAP_ATTRIBUTES );
174- $ this ->whenRequestBaseUrl (self ::BASE_URL );
175- $ this ->whenGeneratedLogoutPath (self ::LOGOUT_PATH_WITH_BASE_URL );
176124 $ this ->whenPathAccess (false );
177- $ this ->whenIsLogoutPath (true );
178125
179126 $ returnValue = $ this ->accessDecider ->isAccessible ($ this ->request , $ this ->token );
180127 $ this ->assertTrue ($ returnValue );
@@ -185,9 +132,7 @@ public function isAccessible_isNotAccessible_returnFalse(): void
185132 {
186133 $ this ->stubAccessMapReturnsAttributes (self ::ACCESS_MAP_ATTRIBUTES );
187134 $ this ->whenRequestBaseUrl ('' );
188- $ this ->whenGeneratedLogoutPath (self ::LOGOUT_PATH );
189135 $ this ->whenPathAccess (false );
190- $ this ->whenIsLogoutPath (false );
191136
192137 $ returnValue = $ this ->accessDecider ->isAccessible ($ this ->request , $ this ->token );
193138 $ this ->assertFalse ($ returnValue );
0 commit comments