aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Loader/PhpFileLoaderTest.php56
1 files changed, 56 insertions, 0 deletions
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}