DumpedUrlMatcherTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\Matcher;
  11. use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
  12. use Symfony\Component\Routing\RequestContext;
  13. use Symfony\Component\Routing\RouteCollection;
  14. class DumpedUrlMatcherTest extends UrlMatcherTest
  15. {
  16. /**
  17. * @expectedException \LogicException
  18. * @expectedExceptionMessage The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.
  19. */
  20. public function testSchemeRequirement()
  21. {
  22. parent::testSchemeRequirement();
  23. }
  24. /**
  25. * @expectedException \LogicException
  26. * @expectedExceptionMessage The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.
  27. */
  28. public function testSchemeAndMethodMismatch()
  29. {
  30. parent::testSchemeRequirement();
  31. }
  32. protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)
  33. {
  34. static $i = 0;
  35. $class = 'DumpedUrlMatcher'.++$i;
  36. $dumper = new PhpMatcherDumper($routes);
  37. eval('?>'.$dumper->dump(array('class' => $class)));
  38. return new $class($context ?: new RequestContext());
  39. }
  40. }