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\Translation\Tests\Loader;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Translation\Loader\IniFileLoader;
16 use Symfony\Component\Config\Resource\FileResource;
18 class IniFileLoaderTest extends TestCase
20 public function testLoad()
22 $loader = new IniFileLoader();
23 $resource = __DIR__.'/../fixtures/resources.ini';
24 $catalogue = $loader->load($resource, 'en', 'domain1');
26 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
27 $this->assertEquals('en', $catalogue->getLocale());
28 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
31 public function testLoadDoesNothingIfEmpty()
33 $loader = new IniFileLoader();
34 $resource = __DIR__.'/../fixtures/empty.ini';
35 $catalogue = $loader->load($resource, 'en', 'domain1');
37 $this->assertEquals(array(), $catalogue->all('domain1'));
38 $this->assertEquals('en', $catalogue->getLocale());
39 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
43 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
45 public function testLoadNonExistingResource()
47 $loader = new IniFileLoader();
48 $resource = __DIR__.'/../fixtures/non-existing.ini';
49 $loader->load($resource, 'en', 'domain1');