Skip to content

Commit

Permalink
[Translation] Added some tests to QtFileLoader.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vicentgodella committed Jan 15, 2013
1 parent 2b3079f commit 293991d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Expand Up @@ -43,4 +43,24 @@ public function testLoadNonExistingResource()
$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');
}
}
@@ -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>

0 comments on commit 293991d

Please sign in to comment.