PhpMatcherDumperTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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;
  11. use Symfony\Component\Routing\Route;
  12. use Symfony\Component\Routing\RouteCollection;
  13. use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper;
  14. class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase
  15. {
  16. static protected $fixturesPath;
  17. static public function setUpBeforeClass()
  18. {
  19. self::$fixturesPath = realpath(__DIR__.'/../../Fixtures/');
  20. }
  21. public function testDump()
  22. {
  23. $collection = new RouteCollection();
  24. $collection->add('foo', new Route(
  25. '/foo/{bar}',
  26. array('def' => 'test'),
  27. array('bar' => 'baz|symfony')
  28. ));
  29. $collection->add('bar', new Route(
  30. '/bar/{foo}',
  31. array(),
  32. array('_method' => 'GET|head')
  33. ));
  34. $collection->add('baz', new Route(
  35. '/test/baz'
  36. ));
  37. $collection->add('baz2', new Route(
  38. '/test/baz.html'
  39. ));
  40. $collection->add('baz3', new Route(
  41. '/test/baz3/'
  42. ));
  43. $collection->add('baz4', new Route(
  44. '/test/{foo}/'
  45. ));
  46. $dumper = new PhpMatcherDumper($collection);
  47. $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.php', $dumper->dump(), '->dump() dumps basic routes to the correct PHP file.');
  48. }
  49. }