12
12
namespace Symfony \Bundle \SecurityBundle \Tests \Security ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Bundle \SecurityBundle \Security \FirewallConfig ;
15
16
use Symfony \Bundle \SecurityBundle \Security \FirewallContext ;
16
17
use Symfony \Bundle \SecurityBundle \Security \FirewallMap ;
17
18
use Symfony \Component \DependencyInjection \Container ;
18
19
use Symfony \Component \HttpFoundation \Request ;
19
20
use Symfony \Component \HttpFoundation \RequestMatcherInterface ;
21
+ use Symfony \Component \Security \Core \User \UserCheckerInterface ;
22
+ use Symfony \Component \Security \Http \Firewall \ExceptionListener ;
23
+ use Symfony \Component \Security \Http \Firewall \ListenerInterface ;
20
24
21
25
class FirewallMapTest extends TestCase
22
26
{
@@ -58,9 +62,15 @@ public function testGetListeners()
58
62
$ request = new Request ();
59
63
60
64
$ firewallContext = $ this ->getMockBuilder (FirewallContext::class)->disableOriginalConstructor ()->getMock ();
61
- $ firewallContext ->expects ($ this ->once ())->method ('getConfig ' )->willReturn ('CONFIG ' );
62
- $ firewallContext ->expects ($ this ->once ())->method ('getListeners ' )->willReturn ('LISTENERS ' );
63
- $ firewallContext ->expects ($ this ->once ())->method ('getExceptionListener ' )->willReturn ('EXCEPTION LISTENER ' );
65
+
66
+ $ firewallConfig = new FirewallConfig ('main ' , $ this ->getMockBuilder (UserCheckerInterface::class)->getMock ());
67
+ $ firewallContext ->expects ($ this ->once ())->method ('getConfig ' )->willReturn ($ firewallConfig );
68
+
69
+ $ listener = $ this ->getMockBuilder (ListenerInterface::class)->getMock ();
70
+ $ firewallContext ->expects ($ this ->once ())->method ('getListeners ' )->willReturn (array ($ listener ));
71
+
72
+ $ exceptionListener = $ this ->getMockBuilder (ExceptionListener::class)->disableOriginalConstructor ()->getMock ();
73
+ $ firewallContext ->expects ($ this ->once ())->method ('getExceptionListener ' )->willReturn ($ exceptionListener );
64
74
65
75
$ matcher = $ this ->getMockBuilder (RequestMatcherInterface::class)->getMock ();
66
76
$ matcher ->expects ($ this ->once ())
@@ -73,8 +83,8 @@ public function testGetListeners()
73
83
74
84
$ firewallMap = new FirewallMap ($ container , array ('security.firewall.map.context.foo ' => $ matcher ));
75
85
76
- $ this ->assertEquals (array (' LISTENERS ' , ' EXCEPTION LISTENER ' ), $ firewallMap ->getListeners ($ request ));
77
- $ this ->assertEquals (' CONFIG ' , $ firewallMap ->getFirewallConfig ($ request ));
86
+ $ this ->assertEquals (array (array ( $ listener ), $ exceptionListener ), $ firewallMap ->getListeners ($ request ));
87
+ $ this ->assertEquals ($ firewallConfig , $ firewallMap ->getFirewallConfig ($ request ));
78
88
$ this ->assertEquals ('security.firewall.map.context.foo ' , $ request ->attributes ->get (self ::ATTRIBUTE_FIREWALL_CONTEXT ));
79
89
}
80
90
}
0 commit comments