Skip to content

Commit ddf4368

Browse files
committed
respect the API in FirewallContext map
When being merged up, this will make the SecurityBundle tests on master green again.
1 parent 22723da commit ddf4368

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\Security;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
1516
use Symfony\Bundle\SecurityBundle\Security\FirewallContext;
1617
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
1718
use Symfony\Component\DependencyInjection\Container;
1819
use Symfony\Component\HttpFoundation\Request;
1920
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;
2024

2125
class FirewallMapTest extends TestCase
2226
{
@@ -58,9 +62,15 @@ public function testGetListeners()
5862
$request = new Request();
5963

6064
$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);
6474

6575
$matcher = $this->getMockBuilder(RequestMatcherInterface::class)->getMock();
6676
$matcher->expects($this->once())
@@ -73,8 +83,8 @@ public function testGetListeners()
7383

7484
$firewallMap = new FirewallMap($container, array('security.firewall.map.context.foo' => $matcher));
7585

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));
7888
$this->assertEquals('security.firewall.map.context.foo', $request->attributes->get(self::ATTRIBUTE_FIREWALL_CONTEXT));
7989
}
8090
}

0 commit comments

Comments
 (0)