diff options
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php')
-rw-r--r-- | vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php deleted file mode 100644 index 1d58e0ee..00000000 --- a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
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\XliffFileLoader; | ||
15 | use Symfony\Component\Config\Resource\FileResource; | ||
16 | |||
17 | class 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 | } | ||