[Translation] Added some tests to QtFileLoader.
Added one test for testing exception is thrown if resource is not local. Added one test for testing exception is thrown if xml resource is invalid.
This commit is contained in:
parent
2b3079f948
commit
293991df7b
@ -43,4 +43,24 @@ class QtFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$resource = __DIR__.'/../fixtures/non-existing.ts';
|
||||
$loader->load($resource, 'en', 'domain1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
|
||||
*/
|
||||
public function testLoadNonLocalResource()
|
||||
{
|
||||
$loader = new QtFileLoader();
|
||||
$resource = 'http://domain1.com/resources.ts';
|
||||
$loader->load($resource, 'en', 'domain1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
|
||||
*/
|
||||
public function testLoadInvalidResource()
|
||||
{
|
||||
$loader = new QtFileLoader();
|
||||
$resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf';
|
||||
$loader->load($resource, 'en', 'domain1');
|
||||
}
|
||||
}
|
||||
|
23
src/Symfony/Component/Translation/Tests/fixtures/invalid-xml-resources.xlf
vendored
Normal file
23
src/Symfony/Component/Translation/Tests/fixtures/invalid-xml-resources.xlf
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
||||
<file source-language="en" datatype="plaintext" original="file.ext">
|
||||
<body>
|
||||
<trans-unit id="1">
|
||||
<source>foo</source>
|
||||
<target>bar
|
||||
</trans-unit>
|
||||
<trans-unit id="2">
|
||||
<source>extra</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="3">
|
||||
<source>key</source>
|
||||
<target></target>
|
||||
</trans-unit>
|
||||
<trans-unit id="4">
|
||||
<source>test</source>
|
||||
<target>with</target>
|
||||
<note>note</note>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
Reference in New Issue
Block a user