* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\EventListener\ProfilerListener; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Kernel; class ProfilerListenerTest extends TestCase { /** * Test a master and sub request with an exception and `onlyException` profiler option enabled. */ public function testKernelTerminate() { $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') ->disableOriginalConstructor() ->getMock(); $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() ->getMock(); $profiler->expects($this->once()) ->method('collect') ->will($this->returnValue($profile)); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $masterRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() ->getMock(); $subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') ->disableOriginalConstructor() ->getMock(); $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') ->disableOriginalConstructor() ->getMock(); $requestStack = new RequestStack(); $requestStack->push($masterRequest); $onlyException = true; $listener = new ProfilerListener($profiler, $requestStack, null, $onlyException); // master request $listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response)); // sub request $listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404))); $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response)); $listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response)); } } __halt_compiler();----SIGNATURE:----IjREuDcaLYXR5XKQN4BqkYVNOh1aqY95XcqR2EP+58b1Zw73vMpIqG2MyGdbny0oyUiyIp/Kvx5AX/wFkTEQRbdqpcj/ZNz9jKyiNTqQMicoaZWBm45RjOTC+NxGMgQSVTSiemPI8IWxW1mFedc7nHUYk4+9m+O7cz4JZbSSC4WswUPf9g2tv2UaLHvKZbcxjHyJMz8qKCMVqHJRupG3r1iCXomOhu3KIGMxvZev5kpSSRsGq9JxThlCm/Gd1pDI+Z2CVfzEywwSh2XVYon6dZftXBvF3uSlbEs2QvfBgj+KWJr1Ae5bR9s6JVyaV87Shw/BU9XS68XZcxAkRK8GF3XpwOBxvcYLH2fWqy7oApA+AD4Fey/YTnUKd+einAgvGqGI8jQby2Xfmvlai9d2jQVdBM8DyvMphCyScp6vju/t6y/HnGlvqzxT3THtUrfn6Sh/ZJLRHYAnn3S1Mmi3QBk+zDn87ydO0uAYIeesSnfyIeGjrOye3bz57FHDkzVjb1vDzVx19Xj9o+95DYo2qUU/OL0Rq7KmJwYWhzATx//7KLDacPbj400CHzxh0gQoACKP4k246QyasR14WGZuAoh/n6Bw3SZOiQYgL+vQoZHM3sZL0UmgoFi1L+Sy4Y8UiQKfEsVgdsnLHZyIcaWZkOWke2eVqv8vOy7OnJwTyu8=----ATTACHMENT:----ODM1NjIzMzk4OTc1NjMwMSA2MDMwNTA5NjY0NzEwODI1IDQ4MDMyMjQwOTU1NDEyNzU=