PhpFileLoaderTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\Loader;
  11. use Symfony\Component\Config\FileLocator;
  12. use Symfony\Component\Routing\Loader\PhpFileLoader;
  13. use Symfony\Component\Routing\Route;
  14. class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @covers Symfony\Component\Routing\Loader\PhpFileLoader::supports
  18. */
  19. public function testSupports()
  20. {
  21. $loader = new PhpFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
  22. $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
  23. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  24. $this->assertTrue($loader->supports('foo.php', 'php'), '->supports() checks the resource type if specified');
  25. $this->assertFalse($loader->supports('foo.php', 'foo'), '->supports() checks the resource type if specified');
  26. }
  27. public function testLoadWithRoute()
  28. {
  29. $loader = new PhpFileLoader(new FileLocator(array(__DIR__.'/../Fixtures')));
  30. $routeCollection = $loader->load('validpattern.php');
  31. $routes = $routeCollection->all();
  32. $this->assertEquals(1, count($routes), 'One route is loaded');
  33. $this->assertContainsOnly('Symfony\Component\Routing\Route', $routes);
  34. }
  35. }