70fbf306070c653756da680923cc65c46065a40c
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Loader / IniFileLoaderTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection\Tests\Loader;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
17 use Symfony\Component\Config\FileLocator;
18
19 class IniFileLoaderTest extends TestCase
20 {
21     protected static $fixturesPath;
22
23     protected $container;
24     protected $loader;
25
26     public static function setUpBeforeClass()
27     {
28         self::$fixturesPath = realpath(__DIR__.'/../Fixtures/');
29     }
30
31     protected function setUp()
32     {
33         $this->container = new ContainerBuilder();
34         $this->loader = new IniFileLoader($this->container, new FileLocator(self::$fixturesPath.'/ini'));
35     }
36
37     public function testIniFileCanBeLoaded()
38     {
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');
41     }
42
43     /**
44      * @expectedException        \InvalidArgumentException
45      * @expectedExceptionMessage The file "foo.ini" does not exist (in:
46      */
47     public function testExceptionIsRaisedWhenIniFileDoesNotExist()
48     {
49         $this->loader->load('foo.ini');
50     }
51
52     /**
53      * @expectedException        \InvalidArgumentException
54      * @expectedExceptionMessage The "nonvalid.ini" file is not valid.
55      */
56     public function testExceptionIsRaisedWhenIniFileCannotBeParsed()
57     {
58         @$this->loader->load('nonvalid.ini');
59     }
60
61     public function testSupports()
62     {
63         $loader = new IniFileLoader(new ContainerBuilder(), new FileLocator());
64
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');
67     }
68 }