|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\HttpKernel\Tests\EventListener; |
| 13 | + |
| 14 | +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
| 15 | +use Symfony\Component\HttpKernel\Event\PostResponseEvent; |
| 16 | +use Symfony\Component\HttpKernel\EventListener\ProfilerListener; |
| 17 | +use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
| 18 | +use Symfony\Component\HttpKernel\Kernel; |
| 19 | + |
| 20 | +class ProfilerListenerTest extends \PHPUnit_Framework_TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * Test to ensure BC without RequestStack |
| 24 | + * |
| 25 | + * @deprecated Deprecated since version 2.4, to be removed in 3.0. |
| 26 | + */ |
| 27 | + public function testEventsWithoutRequestStack() |
| 28 | + { |
| 29 | + $profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile') |
| 30 | + ->disableOriginalConstructor() |
| 31 | + ->getMock(); |
| 32 | + |
| 33 | + $profiler = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') |
| 34 | + ->disableOriginalConstructor() |
| 35 | + ->getMock(); |
| 36 | + $profiler->expects($this->once()) |
| 37 | + ->method('collect') |
| 38 | + ->will($this->returnValue($profile)); |
| 39 | + |
| 40 | + $kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); |
| 41 | + |
| 42 | + $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') |
| 43 | + ->disableOriginalConstructor() |
| 44 | + ->getMock(); |
| 45 | + |
| 46 | + $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') |
| 47 | + ->disableOriginalConstructor() |
| 48 | + ->getMock(); |
| 49 | + |
| 50 | + $listener = new ProfilerListener($profiler); |
| 51 | + $listener->onKernelRequest(new GetResponseEvent($kernel, $request, Kernel::MASTER_REQUEST)); |
| 52 | + $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, Kernel::MASTER_REQUEST, $response)); |
| 53 | + $listener->onKernelTerminate(new PostResponseEvent($kernel, $request, $response)); |
| 54 | + } |
| 55 | +} |
0 commit comments