4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Tests\Loader
;
14 use Symfony\Component\Translation\Loader\QtFileLoader
;
15 use Symfony\Component\Config\
Resource\FileResource
;
17 class QtFileLoaderTest
extends \PHPUnit_Framework_TestCase
19 protected function setUp()
21 if (!class_exists('Symfony\Component\Config\Loader\Loader')) {
22 $this->markTestSkipped('The "Config" component is not available');
26 public function testLoad()
28 $loader = new QtFileLoader();
29 $resource = __DIR__
.'/../fixtures/resources.ts';
30 $catalogue = $loader->load($resource, 'en', 'resources');
32 $this->assertEquals(array('foo' => 'bar'), $catalogue->all('resources'));
33 $this->assertEquals('en', $catalogue->getLocale());
34 $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
38 * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
40 public function testLoadNonExistingResource()
42 $loader = new QtFileLoader();
43 $resource = __DIR__
.'/../fixtures/non-existing.ts';
44 $loader->load($resource, 'en', 'domain1');
48 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
50 public function testLoadNonLocalResource()
52 $loader = new QtFileLoader();
53 $resource = 'http://domain1.com/resources.ts';
54 $loader->load($resource, 'en', 'domain1');
58 * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
60 public function testLoadInvalidResource()
62 $loader = new QtFileLoader();
63 $resource = __DIR__
.'/../fixtures/invalid-xml-resources.xlf';
64 $loader->load($resource, 'en', 'domain1');