IniFileLoader example

$bundleLoader->registerAliasesForSinglyImplementedInterfaces();
        }
    }

    private function createContainerLoader(ContainerBuilder $container, string $env): DelegatingLoader
    {
        $buildDir = $container->getParameter('kernel.build_dir');
        $locator = new FileLocator();
        $resolver = new LoaderResolver([
            new XmlFileLoader($container$locator$env),
            new YamlFileLoader($container$locator$env),
            new IniFileLoader($container$locator$env),
            new PhpFileLoader($container$locator$envnew ConfigBuilderGenerator($buildDir)),
            new GlobFileLoader($container$locator$env),
            new DirectoryLoader($container$locator$env),
            new ClosureLoader($container$env),
        ]);

        return new DelegatingLoader($resolver);
    }
}
/** * Returns a loader for the container. */
    protected function getContainerLoader(ContainerInterface $container): DelegatingLoader
    {
        $env = $this->getEnvironment();
        $locator = new FileLocator($this);
        $resolver = new LoaderResolver([
            new XmlFileLoader($container$locator$env),
            new YamlFileLoader($container$locator$env),
            new IniFileLoader($container$locator$env),
            new PhpFileLoader($container$locator$envclass_exists(ConfigBuilderGenerator::class) ? new ConfigBuilderGenerator($this->getBuildDir()) : null),
            new GlobFileLoader($container$locator$env),
            new DirectoryLoader($container$locator$env),
            new ClosureLoader($container$env),
        ]);

        return new DelegatingLoader($resolver);
    }

    private function preBoot(): ContainerInterface
    {
        
private LoaderResolver $resolver;

    protected function setUp(): void
    {
        self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');

        $container = new ContainerBuilder();
        $this->resolver = new LoaderResolver([
            new XmlFileLoader($containernew FileLocator(self::$fixturesPath.'/xml')),
            new YamlFileLoader($containernew FileLocator(self::$fixturesPath.'/yaml')),
            new IniFileLoader($containernew FileLocator(self::$fixturesPath.'/ini')),
            new PhpFileLoader($containernew FileLocator(self::$fixturesPath.'/php')),
            new ClosureLoader($container),
        ]);
    }

    public static function provideResourcesToLoad()
    {
        return [
            ['ini_with_wrong_ext.xml', 'ini', IniFileLoader::class],
            ['xml_with_wrong_ext.php', 'xml', XmlFileLoader::class],
            ['php_with_wrong_ext.yml', 'php', PhpFileLoader::class],
            [
public static function setUpBeforeClass(): void
    {
        self::$fixturesPath = realpath(__DIR__.'/../');
    }

    public function testImportWithGlobPattern()
    {
        $container = new ContainerBuilder();
        $loader = new TestFileLoader($containernew FileLocator(self::$fixturesPath));

        $resolver = new LoaderResolver([
            new IniFileLoader($containernew FileLocator(self::$fixturesPath.'/ini')),
            new XmlFileLoader($containernew FileLocator(self::$fixturesPath.'/xml')),
            new PhpFileLoader($containernew FileLocator(self::$fixturesPath.'/php')),
            new YamlFileLoader($containernew FileLocator(self::$fixturesPath.'/yaml')),
        ]);

        $loader->setResolver($resolver);
        $loader->import('{F}ixtures/{xml,yaml}/services2.{yml,xml}');

        $actual = $container->getParameterBag()->all();
        $expected = [
            'a_string' => 'a string',
            
'mixedcase' => ['MixedCaseKey' => 'value'],
            'constant' => \PHP_EOL,
        ];

        $this->assertEquals($expected$actual, '->load() converts XML values to PHP ones');
    }

    public function testLoadImports()
    {
        $container = new ContainerBuilder();
        $resolver = new LoaderResolver([
            new IniFileLoader($containernew FileLocator(self::$fixturesPath.'/ini')),
            new YamlFileLoader($containernew FileLocator(self::$fixturesPath.'/yml')),
            $loader = new XmlFileLoader($containernew FileLocator(self::$fixturesPath.'/xml')),
        ]);
        $loader->setResolver($resolver);
        $loader->load('services4.xml');

        $actual = $container->getParameterBag()->all();
        $expected = [
            'a_string' => 'a string',
            'foo' => 'bar',
            'values' => [
                
/** * Returns a loader for the container. */
    protected function getContainerLoader(ContainerInterface $container): DelegatingLoader
    {
        $env = $this->getEnvironment();
        $locator = new FileLocator($this);
        $resolver = new LoaderResolver([
            new XmlFileLoader($container$locator$env),
            new YamlFileLoader($container$locator$env),
            new IniFileLoader($container$locator$env),
            new PhpFileLoader($container$locator$envclass_exists(ConfigBuilderGenerator::class) ? new ConfigBuilderGenerator($this->getBuildDir()) : null),
            new GlobFileLoader($container$locator$env),
            new DirectoryLoader($container$locator$env),
            new ClosureLoader($container$env),
        ]);

        return new DelegatingLoader($resolver);
    }

    private function preBoot(): ContainerInterface
    {
        

        $container = new ContainerBuilder();
        $loader = new YamlFileLoader($containernew FileLocator(self::$fixturesPath.'/yaml'));
        $loader->load('services2.yml');
        $this->assertEquals(['foo' => 'bar', 'mixedcase' => ['MixedCaseKey' => 'value'], 'values' => [true, false, 0, 1000.3, \PHP_INT_MAX], 'bar' => 'foo', 'escape' => '@escapeme', 'foo_bar' => new Reference('foo_bar')]$container->getParameterBag()->all(), '->load() converts YAML keys to lowercase');
    }

    public function testLoadImports()
    {
        $container = new ContainerBuilder();
        $resolver = new LoaderResolver([
            new IniFileLoader($containernew FileLocator(self::$fixturesPath.'/ini')),
            new XmlFileLoader($containernew FileLocator(self::$fixturesPath.'/xml')),
            new PhpFileLoader($containernew FileLocator(self::$fixturesPath.'/php')),
            $loader = new YamlFileLoader($containernew FileLocator(self::$fixturesPath.'/yaml')),
        ]);
        $loader->setResolver($resolver);
        $loader->load('services4.yml');

        $actual = $container->getParameterBag()->all();
        $expected = [
            'foo' => 'bar',
            'values' => [true, false, \PHP_INT_MAX],
            
namespace Symfony\Component\Translation\Tests\Loader;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Translation\Exception\NotFoundResourceException;
use Symfony\Component\Translation\Loader\IniFileLoader;

class IniFileLoaderTest extends TestCase
{
    public function testLoad()
    {
        $loader = new IniFileLoader();
        $resource = __DIR__.'/../fixtures/resources.ini';
        $catalogue = $loader->load($resource, 'en', 'domain1');

        $this->assertEquals(['foo' => 'bar']$catalogue->all('domain1'));
        $this->assertEquals('en', $catalogue->getLocale());
        $this->assertEquals([new FileResource($resource)]$catalogue->getResources());
    }

    public function testLoadDoesNothingIfEmpty()
    {
        $loader = new IniFileLoader();
        
$bundleLoader->registerAliasesForSinglyImplementedInterfaces();
        }
    }

    private function createContainerLoader(ContainerBuilder $container, string $env): DelegatingLoader
    {
        $buildDir = $container->getParameter('kernel.build_dir');
        $locator = new FileLocator();
        $resolver = new LoaderResolver([
            new XmlFileLoader($container$locator$env),
            new YamlFileLoader($container$locator$env),
            new IniFileLoader($container$locator$env),
            new PhpFileLoader($container$locator$envnew ConfigBuilderGenerator($buildDir)),
            new GlobFileLoader($container$locator$env),
            new DirectoryLoader($container$locator$env),
            new ClosureLoader($container$env),
        ]);

        return new DelegatingLoader($resolver);
    }
}
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;

class IniFileLoaderTest extends TestCase
{
    protected ContainerBuilder $container;
    protected IniFileLoader $loader;

    protected function setUp(): void
    {
        $this->container = new ContainerBuilder();
        $this->loader = new IniFileLoader($this->container, new FileLocator(realpath(__DIR__.'/../Fixtures/').'/ini'));
    }

    public function testIniFileCanBeLoaded()
    {
        $this->loader->load('parameters.ini');
        $this->assertEquals(['foo' => 'bar', 'bar' => '%foo%']$this->container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
    }

    /** * @dataProvider getTypeConversions */
    

        self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
    }

    protected function setUp(): void
    {
        $locator = new FileLocator(self::$fixturesPath);
        $this->container = new ContainerBuilder();
        $this->loader = new DirectoryLoader($this->container, $locator);
        $resolver = new LoaderResolver([
            new PhpFileLoader($this->container, $locator),
            new IniFileLoader($this->container, $locator),
            new YamlFileLoader($this->container, $locator),
            $this->loader,
        ]);
        $this->loader->setResolver($resolver);
    }

    public function testDirectoryCanBeLoadedRecursively()
    {
        $this->loader->load('directory/');
        $this->assertEquals(['ini' => 'ini', 'yaml' => 'yaml', 'php' => 'php']$this->container->getParameterBag()->all(), '->load() takes a single directory');
    }

    
Home | Imprint | This part of the site doesn't use cookies.