* * 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:----qPhiGrRYkrUsKyJr2vViIT/Ugb0XSBB0yjm6QZF56Hlu9zSSakoZmWodZqnL9Mvd5IgXXO3O0vzbRoXHk8f8FRSd6muwRFijepjsjDbNI/IK5hkCg+KZlYjOh5PXIE+pcqC7BnRZVHAi1HaATujuJZJIBo41zIBQJCnAFYf8a/emPlR5dnI8EWqCmkVFZ/R3KPVbeC2CI8qJsz2GXwQjqoQ51PGags/0+2ZqK7wgzsLD/C8v6lUKzUVLfV3fT6TPSQMPWSlsPNkgmuzR4pyidlEBJya94M+YRKBR+QnlcmQSgy4z/i1hgIAWSOjwwkPhAoVVIVquK42cDKGM6ldEk0uiGXt7i1Cb5UkJtgtNToL/cjTMOjDjOVRN+dhuv4rmjYHiQS6FtzEanN12RKT/M0TO2iau2ORHEK2kYtzAXe1vz+w6DwDVq4JClsk00fTiT45IKo/V1KmlNsa+xvF9WObCWJ1mVvuIqufeKI/Vy81svdA9bfwiwkifNTzJeSKc8A3FeciEfSdManXqpdZUpE+4NZ1SBqStfQF5IQW45cBFINIRo6fSAODcBP5LF8YOCG4QbchE/uTbPZsCq3FusqesOciZIm5xfkQVVh+t3hyz6iu8lDKYtJxzcoDeGyCfg3z5aIj2IH/FUNpZCnCWGPB7eNNQJdJoIr3CLT5qQmQ=----ATTACHMENT:----OTM3ODQzNTk2NzYzOTgyMSA4MTg3ODA2MzYwNjg2NjQ1IDE2NTgwOTkyMjY4Njk1OTM=