diff options
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php')
-rw-r--r-- | vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php new file mode 100644 index 00000000..cd3d85a1 --- /dev/null +++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php | |||
@@ -0,0 +1,79 @@ | |||
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\PoFileLoader; | ||
15 | use Symfony\Component\Config\Resource\FileResource; | ||
16 | |||
17 | class PoFileLoaderTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | if (!class_exists('Symfony\Component\Config\Loader\Loader')) { | ||
22 | $this->markTestSkipped('The "Config" component is not available'); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | public function testLoad() | ||
27 | { | ||
28 | $loader = new PoFileLoader(); | ||
29 | $resource = __DIR__.'/../fixtures/resources.po'; | ||
30 | $catalogue = $loader->load($resource, 'en', 'domain1'); | ||
31 | |||
32 | $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1')); | ||
33 | $this->assertEquals('en', $catalogue->getLocale()); | ||
34 | $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); | ||
35 | } | ||
36 | |||
37 | public function testLoadPlurals() | ||
38 | { | ||
39 | $loader = new PoFileLoader(); | ||
40 | $resource = __DIR__.'/../fixtures/plurals.po'; | ||
41 | $catalogue = $loader->load($resource, 'en', 'domain1'); | ||
42 | |||
43 | $this->assertEquals(array('foo' => 'bar', 'foos' => 'bar|bars'), $catalogue->all('domain1')); | ||
44 | $this->assertEquals('en', $catalogue->getLocale()); | ||
45 | $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); | ||
46 | } | ||
47 | |||
48 | public function testLoadDoesNothingIfEmpty() | ||
49 | { | ||
50 | $loader = new PoFileLoader(); | ||
51 | $resource = __DIR__.'/../fixtures/empty.po'; | ||
52 | $catalogue = $loader->load($resource, 'en', 'domain1'); | ||
53 | |||
54 | $this->assertEquals(array(), $catalogue->all('domain1')); | ||
55 | $this->assertEquals('en', $catalogue->getLocale()); | ||
56 | $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException | ||
61 | */ | ||
62 | public function testLoadNonExistingResource() | ||
63 | { | ||
64 | $loader = new PoFileLoader(); | ||
65 | $resource = __DIR__.'/../fixtures/non-existing.po'; | ||
66 | $loader->load($resource, 'en', 'domain1'); | ||
67 | } | ||
68 | |||
69 | public function testLoadEmptyTranslation() | ||
70 | { | ||
71 | $loader = new PoFileLoader(); | ||
72 | $resource = __DIR__.'/../fixtures/empty-translation.po'; | ||
73 | $catalogue = $loader->load($resource, 'en', 'domain1'); | ||
74 | |||
75 | $this->assertEquals(array('foo' => ''), $catalogue->all('domain1')); | ||
76 | $this->assertEquals('en', $catalogue->getLocale()); | ||
77 | $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); | ||
78 | } | ||
79 | } | ||