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\DependencyInjection\Tests\Loader;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\FileLocator;
16 use Symfony\Component\Config\Loader\LoaderResolver;
17 use Symfony\Component\DependencyInjection\ContainerBuilder;
18 use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
19 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
20 use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
21 use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
22 use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
24 class LoaderResolverTest extends TestCase
26 private static $fixturesPath;
28 /** @var LoaderResolver */
31 protected function setUp()
33 self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
35 $container = new ContainerBuilder();
36 $this->resolver = new LoaderResolver(array(
37 new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
38 new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
39 new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')),
40 new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')),
41 new ClosureLoader($container),
45 public function provideResourcesToLoad()
48 array('ini_with_wrong_ext.xml', 'ini', IniFileLoader::class),
49 array('xml_with_wrong_ext.php', 'xml', XmlFileLoader::class),
50 array('php_with_wrong_ext.yml', 'php', PhpFileLoader::class),
51 array('yaml_with_wrong_ext.ini', 'yaml', YamlFileLoader::class),
56 * @dataProvider provideResourcesToLoad
58 public function testResolvesForcedType($resource, $type, $expectedClass)
60 $this->assertInstanceOf($expectedClass, $this->resolver->resolve($resource, $type));