HttpKernelTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\HttpKernel;
  11. use Symfony\Component\HttpKernel\HttpKernel;
  12. use Symfony\Component\HttpKernel\HttpKernelInterface;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\EventDispatcher\EventDispatcher;
  16. class HttpKernelTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testHandleSetsTheRequest()
  19. {
  20. $request = Request::create('/');
  21. $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  22. $container->expects($this->exactly(2))
  23. ->method('set')
  24. ->with('request', $request)
  25. ;
  26. $kernel = new HttpKernel($container, new EventDispatcher(), $this->getResolver());
  27. $kernel->handle($request);
  28. }
  29. protected function getResolver($controller = null)
  30. {
  31. if (null === $controller) {
  32. $controller = function () { return new Response('Hello'); };
  33. }
  34. $resolver = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolverInterface');
  35. $resolver->expects($this->any())
  36. ->method('getController')
  37. ->will($this->returnValue($controller))
  38. ;
  39. $resolver->expects($this->any())
  40. ->method('getArguments')
  41. ->will($this->returnValue(array()))
  42. ;
  43. return $resolver;
  44. }
  45. }