InternalControllerTest.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Bundle\FrameworkBundle\Tests\Controller;
  11. use Symfony\Bundle\FrameworkBundle\Controller\InternalController;
  12. use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
  13. use Symfony\Component\HttpFoundation\Request;
  14. class InternalControllerTest extends TestCase
  15. {
  16. /**
  17. * @expectedException \RuntimeException
  18. * @expectedExceptionMessage A Controller class name must end with Controller.
  19. */
  20. public function testWithAClassMethodController()
  21. {
  22. $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  23. $controller = new InternalController();
  24. $controller->setContainer($container);
  25. $controller->indexAction('/', 'Symfony\Component\HttpFoundation\Request::getPathInfo');
  26. }
  27. /**
  28. * @expectedException \RuntimeException
  29. * @expectedExceptionMessage A Controller class name must end with Controller.
  30. */
  31. public function testWithAServiceController()
  32. {
  33. $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
  34. $container
  35. ->expects($this->once())
  36. ->method('get')
  37. ->will($this->returnValue(new Request()))
  38. ;
  39. $controller = new InternalController();
  40. $controller->setContainer($container);
  41. $controller->indexAction('/', 'service:method');
  42. }
  43. }