RouteTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Tests\Component\Routing\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('requirements', array('_method' => 'GET'), 'getRequirements'),
  34. array('options', array('segment_separators' => array('/')), 'getOptions'),
  35. array('name', 'blog_index', 'getName'),
  36. array('defaults', array('_controller' => 'MyBlogBundle:Blog:index'), 'getDefaults')
  37. );
  38. }
  39. }