Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / translation / Tests / Loader / QtFileLoaderTest.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\QtFileLoader;
17
18 class QtFileLoaderTest extends TestCase
19 {
20     public function testLoad()
21     {
22         $loader = new QtFileLoader();
23         $resource = __DIR__.'/../fixtures/resources.ts';
24         $catalogue = $loader->load($resource, 'en', 'resources');
25
26         $this->assertEquals(array('foo' => 'bar'), $catalogue->all('resources'));
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 QtFileLoader();
37         $resource = __DIR__.'/../fixtures/non-existing.ts';
38         $loader->load($resource, 'en', 'domain1');
39     }
40
41     /**
42      * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
43      */
44     public function testLoadNonLocalResource()
45     {
46         $loader = new QtFileLoader();
47         $resource = 'http://domain1.com/resources.ts';
48         $loader->load($resource, 'en', 'domain1');
49     }
50
51     /**
52      * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
53      */
54     public function testLoadInvalidResource()
55     {
56         $loader = new QtFileLoader();
57         $resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf';
58         $loader->load($resource, 'en', 'domain1');
59     }
60
61     public function testLoadEmptyResource()
62     {
63         $loader = new QtFileLoader();
64         $resource = __DIR__.'/../fixtures/empty.xlf';
65
66         if (method_exists($this, 'expectException')) {
67             $this->expectException('Symfony\Component\Translation\Exception\InvalidResourceException');
68             $this->expectExceptionMessage(sprintf('Unable to load "%s".', $resource));
69         } else {
70             $this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
71         }
72
73         $loader->load($resource, 'en', 'domain1');
74     }
75 }