Yaffs site version 1.1
[yaffs-website] / vendor / symfony / translation / Tests / Loader / IcuDatFileLoaderTest.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\Translation\Tests\Loader;
13
14 use Symfony\Component\Translation\Loader\IcuDatFileLoader;
15 use Symfony\Component\Config\Resource\FileResource;
16
17 /**
18  * @requires extension intl
19  */
20 class IcuDatFileLoaderTest extends LocalizedTestCase
21 {
22     /**
23      * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
24      */
25     public function testLoadInvalidResource()
26     {
27         $loader = new IcuDatFileLoader();
28         $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
29     }
30
31     public function testDatEnglishLoad()
32     {
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');
39
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());
43     }
44
45     public function testDatFrenchLoad()
46     {
47         $loader = new IcuDatFileLoader();
48         $resource = __DIR__.'/../fixtures/resourcebundle/dat/resources';
49         $catalogue = $loader->load($resource, 'fr', 'domain1');
50
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());
54     }
55
56     /**
57      * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
58      */
59     public function testLoadNonExistingResource()
60     {
61         $loader = new IcuDatFileLoader();
62         $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
63     }
64 }