* * 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\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Http\Firewall; class FirewallTest extends TestCase { public function testOnKernelRequestRegistersExceptionListener() { $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); $listener = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ExceptionListener')->disableOriginalConstructor()->getMock(); $listener ->expects($this->once()) ->method('register') ->with($this->equalTo($dispatcher)) ; $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(); $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') ->with($this->equalTo($request)) ->will($this->returnValue(array(array(), $listener))) ; $event = new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST); $firewall = new Firewall($map, $dispatcher); $firewall->onKernelRequest($event); } public function testOnKernelRequestStopsWhenThereIsAResponse() { $response = new Response(); $first = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $first ->expects($this->once()) ->method('handle') ; $second = $this->getMockBuilder('Symfony\Component\Security\Http\Firewall\ListenerInterface')->getMock(); $second ->expects($this->never()) ->method('handle') ; $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->once()) ->method('getListeners') ->will($this->returnValue(array(array($first, $second), null))) ; $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') ->setMethods(array('hasResponse')) ->setConstructorArgs(array( $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock(), HttpKernelInterface::MASTER_REQUEST, )) ->getMock() ; $event ->expects($this->once()) ->method('hasResponse') ->will($this->returnValue(true)) ; $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); } public function testOnKernelRequestWithSubRequest() { $map = $this->getMockBuilder('Symfony\Component\Security\Http\FirewallMapInterface')->getMock(); $map ->expects($this->never()) ->method('getListeners') ; $event = new GetResponseEvent( $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(), HttpKernelInterface::SUB_REQUEST ); $firewall = new Firewall($map, $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock()); $firewall->onKernelRequest($event); $this->assertFalse($event->hasResponse()); } } __halt_compiler();----SIGNATURE:----d4SWZZkg7VSC0QzVxQ0CSvs7dQt5UapHaFRfzRUs0Hs08ioyw22ZRdzttJZE0EdW6/f0OzeZO3izUep2kkzKdudngOoTXWqM0iVUZBr/dhpIAVHZ9DziDdhzfRsmVnEfxJj6+gBObOW9ODHWsAvsuk+tGoYVMqKTKDEriYk2X+2In2xbhVIcObF0w+igz4q7nkgJ2fzz38O7r+XARmMSemnFx8edoZAYfAjhhryRt8dHorkCC4DwPjmVzvuZ03XdpFKBkBRXvQZ8OuOFCL4YUFY2P6qrGUdF88ASpA9r3vILFFpHLw1WYRDG1xBfGnek7ulp8ySQkgFjheqHXnLdZ6RKRUTRVGk/f29UqsEZm04nQ4FA4JkBNEPHqdnSTWOnibWewzFkfAKLZEVHXhEhGAIY3qzKeOPSXtjDn5CgVNKmn5zdeILCUaKmMwTwWpiCpH/SQlIfXAKilDbzpwhMYinD6NTVXasSTKoTxPqlrP1SCgekpDCGy1tEnFNZbG2rEAWNjlK8PtK0zO6sikXt2Fm70RBGosBsUoLrUUsAX3GAr0qGJ4ulMWqO9J+ROC2zutZ8tkMsGoh76dW69UblrEIYVul4QhhqxV7dkMfmOy6WxZvvvJ75N9ZlkKTCechC3acFQr5u42jD4b42V7LLrN0fefInO4fNJIP3k61REFQ=----ATTACHMENT:----ODEzNzg3NDc1Nzg5Mzg5IDczNTI0MTE5NTI0MjIzIDM4MTkwNzg1OTY5OTA5OTM=