@@ -169,6 +169,38 @@ public function testLogin()
169169 $ security ->login ($ user );
170170 }
171171
172+ public function testLoginWithoutAuthenticatorThrows ()
173+ {
174+ $ request = new Request ();
175+ $ authenticator = $ this ->createMock (AuthenticatorInterface::class);
176+ $ requestStack = $ this ->createMock (RequestStack::class);
177+ $ firewallMap = $ this ->createMock (FirewallMap::class);
178+ $ firewall = new FirewallConfig ('main ' , 'main ' );
179+ $ user = $ this ->createMock (UserInterface::class);
180+ $ userChecker = $ this ->createMock (UserCheckerInterface::class);
181+
182+ $ container = $ this ->createMock (ContainerInterface::class);
183+ $ container
184+ ->expects ($ this ->atLeastOnce ())
185+ ->method ('get ' )
186+ ->willReturnMap ([
187+ ['request_stack ' , $ requestStack ],
188+ ['security.firewall.map ' , $ firewallMap ],
189+ ['security.user_checker ' , $ userChecker ],
190+ ])
191+ ;
192+
193+ $ requestStack ->expects ($ this ->once ())->method ('getCurrentRequest ' )->willReturn ($ request );
194+ $ firewallMap ->expects ($ this ->once ())->method ('getFirewallConfig ' )->willReturn ($ firewall );
195+
196+ $ security = new Security ($ container , ['main ' => null ]);
197+
198+ $ this ->expectException (\LogicException::class);
199+ $ this ->expectExceptionMessage ('No authenticators found for firewall "main". ' );
200+
201+ $ security ->login ($ user );
202+ }
203+
172204 public function testLogout ()
173205 {
174206 $ request = new Request ();
0 commit comments