* * 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:----hGEQsWR1gs3BM954CNCI3COiovldrfeA5pGl0nYGjovPS4e4I/YaZpyri2L4BbPCd8A9Bl6aSeGGRO+pvcr/FyH5kaUFsApxkTh1ySEwZh+ienOV7H5awauHgZGLOZaZ++MMpndr8vjTmvojXnFcFlWOTF2eTsx+7LT1CooqR+FyU1aL4z8B7pIfRkVw4FZxZZo+e19pjc3cypOTxDjMDxvs/ks4XYMsKfOWlG6zWR2c/zE4YVAEvE+enEjrfqPmNV2MzCMdSOrAgtJ21sRRcdXGfqVZWzuP/csTMJ1hcFg9K63GfF+sxNGvrO5QqPjFWycz0CNRO3+dwAhp9rNUKbAETGJATcbEkxSQ6/XbWBFMRvJX61Uykq/EyUB5/Nrxcg+OoDfABsruPS/wsKmWqBPIZKr9wxK0G/kP2x/P4psaB77UzxAaTvJvGnKVqmTKAjGEa7al3o0shbx78B/4anH6jV2Vwo3OiEXdDezqBnre9TmfQZJN+X+MNPyxdwCrV6FkTgmhOAzMWzxeo2zjaFJRDpewb62T7tEi4JDFO5XNCbkLxpzxIu/SP+LVjaRSwEKO+BG6I2//t0zn9oq6dIXyRiUrNYLVKmVb0b/9PMxScOaNl8EDfKtyrZM1j9oPh0qWvnUgEh/2bM9ZKtSooNGNvm3jNmfhHeyVhl5++I8=----ATTACHMENT:----OTM2MDUxNTUyNjc5NDUwMyAyMDQwMjk2MzM4ODQ4NzkwIDkyNzg3MTc1MDY2NDIwNzI=