* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Http\FirewallMap; use Symfony\Component\HttpFoundation\Request; class FirewallMapTest extends TestCase { public function testGetListeners() { $map = new FirewallMap(); $request = new Request(); $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(false)) ; $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); $matchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $matchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(true)) ; $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add($matchingMatcher, array($theListener), $theException); $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); $this->assertEquals(array($theListener), $listeners); $this->assertEquals($theException, $exception); } public function testGetListenersWithAnEntryHavingNoRequestMatcher() { $map = new FirewallMap(); $request = new Request(); $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(false)) ; $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); $theListener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $theException = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $map->add(null, array($theListener), $theException); $tooLateMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $tooLateMatcher ->expects($this->never()) ->method('matches') ; $map->add($tooLateMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); $this->assertEquals(array($theListener), $listeners); $this->assertEquals($theException, $exception); } public function testGetListenersWithNoMatchingEntry() { $map = new FirewallMap(); $request = new Request(); $notMatchingMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcher')->getMock(); $notMatchingMatcher ->expects($this->once()) ->method('matches') ->with($this->equalTo($request)) ->will($this->returnValue(false)) ; $map->add($notMatchingMatcher, array($this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock())); list($listeners, $exception) = $map->getListeners($request); $this->assertEquals(array(), $listeners); $this->assertNull($exception); } } __halt_compiler();----SIGNATURE:----rmhyYHIiM/EICodjWHkRG+9Ops4mE+0af1tK32YPezJQgkT2gezhRNV2HXGlglU2LdraphvhR4Q4mIqtDHnmW7iQZ0ACY+Ep8p1wujabjKxjFcJSHvVesDCkUBbsibsFHoGExbwf86VcKeujSZMqszhM52hesd2b9zyjrjSu5xVD+VU87GbMRXgI1kSCClpd1Kn7WmR8bj8TrKwRLO7mXRRWLZfAEw2QT9r6P3UZDGqVo7DdK6jk930e8G5Sy4tE9cQn8ZCgYhWSM0z1fc86zTpNR5G0p0PSvamzjI8opr4wzcfoiJX8y7UxX2Jr49PjLlID91DB2TuEFvG8VLAfL1Z19BNc3wPzVnc01yjdnQD/l1FlKcUIpvw5Tv43CcgC8o1FkrpROJ8gCJk026t48uMPKTcVIhjoYWS6IGO/9h6sLfhAyNAcA8CjIA74F7r0vctaVShKI/smiHyMrXFyQvM25LmFlY3bej8MphhX0AputZBd5uEexZ+g2Ot1jpGdt+22iGOKgMMfHUaxQUNxLdLD6qePZCEdIk8MlEgol/TxAY0BFDrGiyqq6JUlNpKP9FDtZnsMssX7n4oBk2Hbn08o29lxDQy6cdzEjzYASBUFdDYHmUtN6A/TiIDFFMrENctUb6bzRZOYKBeh5sdwEd3OM1XnQIA6kohY6Bg/Id0=----ATTACHMENT:----NTg5MzY4MDQxMzMxNjczOCAyMDA4MjM3NzA2NTk4MDA5IDgzMTEwMTcyNTMyOTgwNDk=