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 Symfony\Component\Translation\Loader\IcuResFileLoader
;
15 use Symfony\Component\Config\
Resource\DirectoryResource
;
17 class IcuResFileLoaderTest
extends LocalizedTestCase
19 protected function setUp()
21 if (!class_exists('Symfony\Component\Config\Loader\Loader')) {
22 $this->markTestSkipped('The "Config" component is not available');
25 if (!extension_loaded('intl')) {
26 $this->markTestSkipped('This test requires intl extension to work.');
30 public function testLoad()
32 // resource is build using genrb command
33 $loader = new IcuResFileLoader();
34 $resource = __DIR__
.'/../fixtures/resourcebundle/res';
35 $catalogue = $loader->load($resource, 'en', 'domain1');
37 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
38 $this->assertEquals('en', $catalogue->getLocale());
39 $this->assertEquals(array(new DirectoryResource($resource)), $catalogue->getResources());
43 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
45 public function testLoadNonExistingResource()
47 $loader = new IcuResFileLoader();
48 $loader->load(__DIR__
.'/../fixtures/non-existing.txt', 'en', 'domain1');
52 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
54 public function testLoadInvalidResource()
56 $loader = new IcuResFileLoader();
57 $loader->load(__DIR__
.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1');