01b7a5feab7266b74396d28eef6e733aba5169c0
[yaffs-website] / vendor / symfony / translation / Tests / Loader / PhpFileLoaderTest.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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Resource\FileResource;
16 use Symfony\Component\Translation\Loader\PhpFileLoader;
17
18 class PhpFileLoaderTest extends TestCase
19 {
20     public function testLoad()
21     {
22         $loader = new PhpFileLoader();
23         $resource = __DIR__.'/../fixtures/resources.php';
24         $catalogue = $loader->load($resource, 'en', 'domain1');
25
26         $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
27         $this->assertEquals('en', $catalogue->getLocale());
28         $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
29     }
30
31     /**
32      * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
33      */
34     public function testLoadNonExistingResource()
35     {
36         $loader = new PhpFileLoader();
37         $resource = __DIR__.'/../fixtures/non-existing.php';
38         $loader->load($resource, 'en', 'domain1');
39     }
40
41     /**
42      * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
43      */
44     public function testLoadThrowsAnExceptionIfFileNotLocal()
45     {
46         $loader = new PhpFileLoader();
47         $resource = 'http://example.com/resources.php';
48         $loader->load($resource, 'en', 'domain1');
49     }
50 }