LoaderResolverTest.php 1.8 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\Config\Tests\Loader;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Config\Loader\LoaderResolver;
  13. class LoaderResolverTest extends TestCase
  14. {
  15. public function testConstructor()
  16. {
  17. $resolver = new LoaderResolver(array(
  18. $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(),
  19. ));
  20. $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
  21. }
  22. public function testResolve()
  23. {
  24. $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
  25. $resolver = new LoaderResolver(array($loader));
  26. $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
  27. $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
  28. $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
  29. $resolver = new LoaderResolver(array($loader));
  30. $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
  31. }
  32. public function testLoaders()
  33. {
  34. $resolver = new LoaderResolver();
  35. $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock());
  36. $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
  37. }
  38. }