LoaderResolverTest.php 2.0 KB

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