RouteTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Component\Routing\Tests\Annotation;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. class RouteTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @expectedException \BadMethodCallException
  16. */
  17. public function testInvalidRouteParameter()
  18. {
  19. $route = new Route(array('foo' => 'bar'));
  20. }
  21. /**
  22. * @dataProvider getValidParameters
  23. */
  24. public function testRouteParameters($parameter, $value, $getter)
  25. {
  26. $route = new Route(array($parameter => $value));
  27. $this->assertEquals($route->$getter(), $value);
  28. }
  29. public function getValidParameters()
  30. {
  31. return array(
  32. array('value', '/Blog', 'getPattern'),
  33. array('value', '/Blog', 'getPath'),
  34. array('requirements', array('_method' => 'GET'), 'getRequirements'),
  35. array('options', array('compiler_class' => 'RouteCompiler'), 'getOptions'),
  36. array('name', 'blog_index', 'getName'),
  37. array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults'),
  38. array('schemes', array('https'), 'getSchemes'),
  39. array('methods', array('GET', 'POST'), 'getMethods'),
  40. array('host', array('{locale}.example.com'), 'getHost')
  41. );
  42. }
  43. }