4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Tests\Loader;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Loader\LoaderResolver;
17 class LoaderResolverTest extends TestCase
19 public function testConstructor()
21 $resolver = new LoaderResolver(array(
22 $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(),
25 $this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
28 public function testResolve()
30 $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
31 $resolver = new LoaderResolver(array($loader));
32 $this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
34 $loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
35 $loader->expects($this->once())->method('supports')->will($this->returnValue(true));
36 $resolver = new LoaderResolver(array($loader));
37 $this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
40 public function testLoaders()
42 $resolver = new LoaderResolver();
43 $resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock());
45 $this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');