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\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
17 use Symfony\Component\Config\FileLocator;
19 class IniFileLoaderTest extends TestCase
21 protected static $fixturesPath;
26 public static function setUpBeforeClass()
28 self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
31 protected function setUp()
33 $this->container = new ContainerBuilder();
34 $this->loader = new IniFileLoader($this->container, new FileLocator(self::$fixturesPath.'/ini'));
37 public function testIniFileCanBeLoaded()
39 $this->loader->load('parameters.ini');
40 $this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $this->container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
44 * @expectedException \InvalidArgumentException
45 * @expectedExceptionMessage The file "foo.ini" does not exist (in:
47 public function testExceptionIsRaisedWhenIniFileDoesNotExist()
49 $this->loader->load('foo.ini');
53 * @expectedException \InvalidArgumentException
54 * @expectedExceptionMessage The "nonvalid.ini" file is not valid.
56 public function testExceptionIsRaisedWhenIniFileCannotBeParsed()
58 @$this->loader->load('nonvalid.ini');
61 public function testSupports()
63 $loader = new IniFileLoader(new ContainerBuilder(), new FileLocator());
65 $this->assertTrue($loader->supports('foo.ini'), '->supports() returns true if the resource is loadable');
66 $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');