LoaderResolverTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Symfony\Tests\Component\Routing\Loader;
  10. use Symfony\Component\Routing\Loader\LoaderResolver;
  11. use Symfony\Component\Routing\Loader\ClosureLoader;
  12. class LoaderResolverTest extends \PHPUnit_Framework_TestCase
  13. {
  14. /**
  15. * @covers Symfony\Component\Routing\Loader\LoaderResolver::__construct
  16. */
  17. public function testConstructor()
  18. {
  19. $resolver = new LoaderResolver(array(
  20. $loader = new ClosureLoader(),
  21. ));
  22. $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
  23. }
  24. /**
  25. * @covers Symfony\Component\Routing\Loader\LoaderResolver::resolve
  26. */
  27. public function testResolve()
  28. {
  29. $resolver = new LoaderResolver(array(
  30. $loader = new ClosureLoader(),
  31. ));
  32. $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
  33. $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
  34. }
  35. /**
  36. * @covers Symfony\Component\Routing\Loader\LoaderResolver::getLoaders
  37. * @covers Symfony\Component\Routing\Loader\LoaderResolver::addLoader
  38. */
  39. public function testLoaders()
  40. {
  41. $resolver = new LoaderResolver();
  42. $resolver->addLoader($loader = new ClosureLoader());
  43. $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
  44. }
  45. }