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\IcuDatFileLoader;
15 use Symfony\Component\Config\Resource\FileResource;
18 * @requires extension intl
20 class IcuDatFileLoaderTest extends LocalizedTestCase
23 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
25 public function testLoadInvalidResource()
27 $loader = new IcuDatFileLoader();
28 $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
31 public function testDatEnglishLoad()
33 // bundled resource is build using pkgdata command which at least in ICU 4.2 comes in extremely! buggy form
34 // you must specify an temporary build directory which is not the same as current directory and
35 // MUST reside on the same partition. pkgdata -p resources -T /srv -d.packagelist.txt
36 $loader = new IcuDatFileLoader();
37 $resource = __DIR__.'/../fixtures/resourcebundle/dat/resources';
38 $catalogue = $loader->load($resource, 'en', 'domain1');
40 $this->assertEquals(array('symfony' => 'Symfony 2 is great'), $catalogue->all('domain1'));
41 $this->assertEquals('en', $catalogue->getLocale());
42 $this->assertEquals(array(new FileResource($resource.'.dat')), $catalogue->getResources());
45 public function testDatFrenchLoad()
47 $loader = new IcuDatFileLoader();
48 $resource = __DIR__.'/../fixtures/resourcebundle/dat/resources';
49 $catalogue = $loader->load($resource, 'fr', 'domain1');
51 $this->assertEquals(array('symfony' => 'Symfony 2 est génial'), $catalogue->all('domain1'));
52 $this->assertEquals('fr', $catalogue->getLocale());
53 $this->assertEquals(array(new FileResource($resource.'.dat')), $catalogue->getResources());
57 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
59 public function testLoadNonExistingResource()
61 $loader = new IcuDatFileLoader();
62 $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');