ApacheMatcherDumperTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\ApacheMatcherDumper;
  14. class ApacheMatcherDumperTest 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->addRoute('foo', new Route(
  25. '/foo/:bar',
  26. array('def' => 'test'),
  27. array('bar' => 'baz|symfony')
  28. ));
  29. $collection->addRoute('bar', new Route(
  30. '/bar/:foo',
  31. array(),
  32. array('_method' => array('GET', 'HEAD'))
  33. ));
  34. $dumper = new ApacheMatcherDumper($collection);
  35. $this->assertStringEqualsFile(self::$fixturesPath.'/dumper/url_matcher1.apache', $dumper->dump(), '->dump() dumps basic routes to the correct apache format.');
  36. }
  37. }