aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php67
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php72
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php59
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php57
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/LocalizedTestCase.php22
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php67
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php56
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php79
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php66
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php113
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php81
11 files changed, 739 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php
new file mode 100644
index 00000000..59569a3d
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/CsvFileLoaderTest.php
@@ -0,0 +1,67 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\CsvFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class CsvFileLoaderTest 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 CsvFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.csv';
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 testLoadDoesNothingIfEmpty()
38 {
39 $loader = new CsvFileLoader();
40 $resource = __DIR__.'/../fixtures/empty.csv';
41 $catalogue = $loader->load($resource, 'en', 'domain1');
42
43 $this->assertEquals(array(), $catalogue->all('domain1'));
44 $this->assertEquals('en', $catalogue->getLocale());
45 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
46 }
47
48 /**
49 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
50 */
51 public function testLoadNonExistingResource()
52 {
53 $loader = new CsvFileLoader();
54 $resource = __DIR__.'/../fixtures/not-exists.csv';
55 $loader->load($resource, 'en', 'domain1');
56 }
57
58 /**
59 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
60 */
61 public function testLoadNonLocalResource()
62 {
63 $loader = new CsvFileLoader();
64 $resource = 'http://example.com/resources.csv';
65 $loader->load($resource, 'en', 'domain1');
66 }
67}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php
new file mode 100644
index 00000000..a3bd67ab
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuDatFileLoaderTest.php
@@ -0,0 +1,72 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\IcuDatFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class IcuDatFileLoaderTest extends LocalizedTestCase
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 if (!extension_loaded('intl')) {
26 $this->markTestSkipped('This test requires intl extension to work.');
27 }
28 }
29
30 /**
31 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
32 */
33 public function testLoadInvalidResource()
34 {
35 $loader = new IcuDatFileLoader();
36 $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted/resources', 'es', 'domain2');
37 }
38
39 public function testDatEnglishLoad()
40 {
41 // bundled resource is build using pkgdata command which at least in ICU 4.2 comes in extremely! buggy form
42 // you must specify an temporary build directory which is not the same as current directory and
43 // MUST reside on the same partition. pkgdata -p resources -T /srv -d.packagelist.txt
44 $loader = new IcuDatFileLoader();
45 $resource = __DIR__.'/../fixtures/resourcebundle/dat/resources';
46 $catalogue = $loader->load($resource, 'en', 'domain1');
47
48 $this->assertEquals(array('symfony' => 'Symfony 2 is great'), $catalogue->all('domain1'));
49 $this->assertEquals('en', $catalogue->getLocale());
50 $this->assertEquals(array(new FileResource($resource.'.dat')), $catalogue->getResources());
51 }
52
53 public function testDatFrenchLoad()
54 {
55 $loader = new IcuDatFileLoader();
56 $resource = __DIR__.'/../fixtures/resourcebundle/dat/resources';
57 $catalogue = $loader->load($resource, 'fr', 'domain1');
58
59 $this->assertEquals(array('symfony' => 'Symfony 2 est génial'), $catalogue->all('domain1'));
60 $this->assertEquals('fr', $catalogue->getLocale());
61 $this->assertEquals(array(new FileResource($resource.'.dat')), $catalogue->getResources());
62 }
63
64 /**
65 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
66 */
67 public function testLoadNonExistingResource()
68 {
69 $loader = new IcuDatFileLoader();
70 $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
71 }
72}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php
new file mode 100644
index 00000000..233e1897
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IcuResFileLoaderTest.php
@@ -0,0 +1,59 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\IcuResFileLoader;
15use Symfony\Component\Config\Resource\DirectoryResource;
16
17class IcuResFileLoaderTest extends LocalizedTestCase
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 if (!extension_loaded('intl')) {
26 $this->markTestSkipped('This test requires intl extension to work.');
27 }
28 }
29
30 public function testLoad()
31 {
32 // resource is build using genrb command
33 $loader = new IcuResFileLoader();
34 $resource = __DIR__.'/../fixtures/resourcebundle/res';
35 $catalogue = $loader->load($resource, 'en', 'domain1');
36
37 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
38 $this->assertEquals('en', $catalogue->getLocale());
39 $this->assertEquals(array(new DirectoryResource($resource)), $catalogue->getResources());
40 }
41
42 /**
43 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
44 */
45 public function testLoadNonExistingResource()
46 {
47 $loader = new IcuResFileLoader();
48 $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
49 }
50
51 /**
52 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
53 */
54 public function testLoadInvalidResource()
55 {
56 $loader = new IcuResFileLoader();
57 $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1');
58 }
59}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php
new file mode 100644
index 00000000..ae1289d0
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/IniFileLoaderTest.php
@@ -0,0 +1,57 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\IniFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class IniFileLoaderTest 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 IniFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.ini';
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 testLoadDoesNothingIfEmpty()
38 {
39 $loader = new IniFileLoader();
40 $resource = __DIR__.'/../fixtures/empty.ini';
41 $catalogue = $loader->load($resource, 'en', 'domain1');
42
43 $this->assertEquals(array(), $catalogue->all('domain1'));
44 $this->assertEquals('en', $catalogue->getLocale());
45 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
46 }
47
48 /**
49 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
50 */
51 public function testLoadNonExistingResource()
52 {
53 $loader = new IniFileLoader();
54 $resource = __DIR__.'/../fixtures/non-existing.ini';
55 $loader->load($resource, 'en', 'domain1');
56 }
57}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/LocalizedTestCase.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/LocalizedTestCase.php
new file mode 100644
index 00000000..9d7c5d70
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/LocalizedTestCase.php
@@ -0,0 +1,22 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14abstract class LocalizedTestCase extends \PHPUnit_Framework_TestCase
15{
16 protected function setUp()
17 {
18 if (!extension_loaded('intl')) {
19 $this->markTestSkipped('The "intl" extension is not available');
20 }
21 }
22}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php
new file mode 100644
index 00000000..c2616bda
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/MoFileLoaderTest.php
@@ -0,0 +1,67 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\MoFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class MoFileLoaderTest 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 MoFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.mo';
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 MoFileLoader();
40 $resource = __DIR__.'/../fixtures/plurals.mo';
41 $catalogue = $loader->load($resource, 'en', 'domain1');
42
43 $this->assertEquals(array('foo' => 'bar', 'foos' => '{0} bar|{1} bars'), $catalogue->all('domain1'));
44 $this->assertEquals('en', $catalogue->getLocale());
45 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
46 }
47
48 /**
49 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
50 */
51 public function testLoadNonExistingResource()
52 {
53 $loader = new MoFileLoader();
54 $resource = __DIR__.'/../fixtures/non-existing.mo';
55 $loader->load($resource, 'en', 'domain1');
56 }
57
58 /**
59 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
60 */
61 public function testLoadInvalidResource()
62 {
63 $loader = new MoFileLoader();
64 $resource = __DIR__.'/../fixtures/empty.mo';
65 $loader->load($resource, 'en', 'domain1');
66 }
67}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
new file mode 100644
index 00000000..5dfe837d
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
@@ -0,0 +1,56 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\PhpFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class PhpFileLoaderTest 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 PhpFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.php';
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 /**
38 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
39 */
40 public function testLoadNonExistingResource()
41 {
42 $loader = new PhpFileLoader();
43 $resource = __DIR__.'/../fixtures/non-existing.php';
44 $loader->load($resource, 'en', 'domain1');
45 }
46
47 /**
48 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
49 */
50 public function testLoadThrowsAnExceptionIfFileNotLocal()
51 {
52 $loader = new PhpFileLoader();
53 $resource = 'http://example.com/resources.php';
54 $loader->load($resource, 'en', 'domain1');
55 }
56}
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\PoFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class 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}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php
new file mode 100644
index 00000000..c1dd7b10
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/QtFileLoaderTest.php
@@ -0,0 +1,66 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\QtFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class QtFileLoaderTest 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 QtFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.ts';
30 $catalogue = $loader->load($resource, 'en', 'resources');
31
32 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('resources'));
33 $this->assertEquals('en', $catalogue->getLocale());
34 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
35 }
36
37 /**
38 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
39 */
40 public function testLoadNonExistingResource()
41 {
42 $loader = new QtFileLoader();
43 $resource = __DIR__.'/../fixtures/non-existing.ts';
44 $loader->load($resource, 'en', 'domain1');
45 }
46
47 /**
48 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
49 */
50 public function testLoadNonLocalResource()
51 {
52 $loader = new QtFileLoader();
53 $resource = 'http://domain1.com/resources.ts';
54 $loader->load($resource, 'en', 'domain1');
55 }
56
57 /**
58 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
59 */
60 public function testLoadInvalidResource()
61 {
62 $loader = new QtFileLoader();
63 $resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf';
64 $loader->load($resource, 'en', 'domain1');
65 }
66}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php
new file mode 100644
index 00000000..1d58e0ee
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php
@@ -0,0 +1,113 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\XliffFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class XliffFileLoaderTest 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 XliffFileLoader();
29 $resource = __DIR__.'/../fixtures/resources.xlf';
30 $catalogue = $loader->load($resource, 'en', 'domain1');
31
32 $this->assertEquals('en', $catalogue->getLocale());
33 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
34 }
35
36 public function testLoadWithResname()
37 {
38 $loader = new XliffFileLoader();
39 $catalogue = $loader->load(__DIR__.'/../fixtures/resname.xlf', 'en', 'domain1');
40
41 $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz', 'baz' => 'foo'), $catalogue->all('domain1'));
42 }
43
44 public function testIncompleteResource()
45 {
46 $loader = new XliffFileLoader();
47 $catalogue = $loader->load(__DIR__.'/../fixtures/resources.xlf', 'en', 'domain1');
48
49 $this->assertEquals(array('foo' => 'bar', 'key' => '', 'test' => 'with'), $catalogue->all('domain1'));
50 $this->assertFalse($catalogue->has('extra', 'domain1'));
51 }
52
53 public function testEncoding()
54 {
55 if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) {
56 $this->markTestSkipped('The iconv and mbstring extensions are not available.');
57 }
58
59 $loader = new XliffFileLoader();
60 $catalogue = $loader->load(__DIR__.'/../fixtures/encoding.xlf', 'en', 'domain1');
61
62 $this->assertEquals(utf8_decode('föö'), $catalogue->get('bar', 'domain1'));
63 $this->assertEquals(utf8_decode('bär'), $catalogue->get('foo', 'domain1'));
64 }
65
66 /**
67 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
68 */
69 public function testLoadInvalidResource()
70 {
71 $loader = new XliffFileLoader();
72 $loader->load(__DIR__.'/../fixtures/resources.php', 'en', 'domain1');
73 }
74
75 /**
76 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
77 */
78 public function testLoadResourceDoesNotValidate()
79 {
80 $loader = new XliffFileLoader();
81 $loader->load(__DIR__.'/../fixtures/non-valid.xlf', 'en', 'domain1');
82 }
83
84 /**
85 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
86 */
87 public function testLoadNonExistingResource()
88 {
89 $loader = new XliffFileLoader();
90 $resource = __DIR__.'/../fixtures/non-existing.xlf';
91 $loader->load($resource, 'en', 'domain1');
92 }
93
94 /**
95 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
96 */
97 public function testLoadThrowsAnExceptionIfFileNotLocal()
98 {
99 $loader = new XliffFileLoader();
100 $resource = 'http://example.com/resources.xlf';
101 $loader->load($resource, 'en', 'domain1');
102 }
103
104 /**
105 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
106 * @expectedExceptionMessage Document types are not allowed.
107 */
108 public function testDocTypeIsNotAllowed()
109 {
110 $loader = new XliffFileLoader();
111 $loader->load(__DIR__.'/../fixtures/withdoctype.xlf', 'en', 'domain1');
112 }
113}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php
new file mode 100644
index 00000000..511b1279
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/YamlFileLoaderTest.php
@@ -0,0 +1,81 @@
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
12namespace Symfony\Component\Translation\Tests\Loader;
13
14use Symfony\Component\Translation\Loader\YamlFileLoader;
15use Symfony\Component\Config\Resource\FileResource;
16
17class YamlFileLoaderTest 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 if (!class_exists('Symfony\Component\Yaml\Yaml')) {
26 $this->markTestSkipped('The "Yaml" component is not available');
27 }
28 }
29
30 public function testLoad()
31 {
32 $loader = new YamlFileLoader();
33 $resource = __DIR__.'/../fixtures/resources.yml';
34 $catalogue = $loader->load($resource, 'en', 'domain1');
35
36 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
37 $this->assertEquals('en', $catalogue->getLocale());
38 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
39 }
40
41 public function testLoadDoesNothingIfEmpty()
42 {
43 $loader = new YamlFileLoader();
44 $resource = __DIR__.'/../fixtures/empty.yml';
45 $catalogue = $loader->load($resource, 'en', 'domain1');
46
47 $this->assertEquals(array(), $catalogue->all('domain1'));
48 $this->assertEquals('en', $catalogue->getLocale());
49 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
50 }
51
52 /**
53 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
54 */
55 public function testLoadNonExistingResource()
56 {
57 $loader = new YamlFileLoader();
58 $resource = __DIR__.'/../fixtures/non-existing.yml';
59 $loader->load($resource, 'en', 'domain1');
60 }
61
62 /**
63 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
64 */
65 public function testLoadThrowsAnExceptionIfFileNotLocal()
66 {
67 $loader = new YamlFileLoader();
68 $resource = 'http://example.com/resources.yml';
69 $loader->load($resource, 'en', 'domain1');
70 }
71
72 /**
73 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
74 */
75 public function testLoadThrowsAnExceptionIfNotAnArray()
76 {
77 $loader = new YamlFileLoader();
78 $resource = __DIR__.'/../fixtures/non-valid.yml';
79 $loader->load($resource, 'en', 'domain1');
80 }
81}