RouteTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. class RouteTest extends TestCase
  14. {
  15. /**
  16. * @expectedException \BadMethodCallException
  17. */
  18. public function testInvalidRouteParameter()
  19. {
  20. $route = new Route(array('foo' => 'bar'));
  21. }
  22. /**
  23. * @dataProvider getValidParameters
  24. */
  25. public function testRouteParameters($parameter, $value, $getter)
  26. {
  27. $route = new Route(array($parameter => $value));
  28. $this->assertEquals($route->$getter(), $value);
  29. }
  30. public function getValidParameters()
  31. {
  32. return array(
  33. array('value', '/Blog', 'getPath'),
  34. array('requirements', array('locale' => 'en'), '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', '{locale}.example.com', 'getHost'),
  41. array('condition', 'context.getMethod() == "GET"', 'getCondition'),
  42. );
  43. }
  44. }