説明なし

QtFileLoaderTest.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Tests\Loader;
  11. use Symfony\Component\Translation\Loader\QtFileLoader;
  12. use Symfony\Component\Config\Resource\FileResource;
  13. class QtFileLoaderTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testLoad()
  16. {
  17. $loader = new QtFileLoader();
  18. $resource = __DIR__.'/../fixtures/resources.ts';
  19. $catalogue = $loader->load($resource, 'en', 'resources');
  20. $this->assertEquals(array('foo' => 'bar'), $catalogue->all('resources'));
  21. $this->assertEquals('en', $catalogue->getLocale());
  22. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
  23. }
  24. /**
  25. * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
  26. */
  27. public function testLoadNonExistingResource()
  28. {
  29. $loader = new QtFileLoader();
  30. $resource = __DIR__.'/../fixtures/non-existing.ts';
  31. $loader->load($resource, 'en', 'domain1');
  32. }
  33. /**
  34. * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
  35. */
  36. public function testLoadNonLocalResource()
  37. {
  38. $loader = new QtFileLoader();
  39. $resource = 'http://domain1.com/resources.ts';
  40. $loader->load($resource, 'en', 'domain1');
  41. }
  42. /**
  43. * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
  44. */
  45. public function testLoadInvalidResource()
  46. {
  47. $loader = new QtFileLoader();
  48. $resource = __DIR__.'/../fixtures/invalid-xml-resources.xlf';
  49. $loader->load($resource, 'en', 'domain1');
  50. }
  51. public function testLoadEmptyResource()
  52. {
  53. $loader = new QtFileLoader();
  54. $resource = __DIR__.'/../fixtures/empty.xlf';
  55. $this->setExpectedException('Symfony\Component\Translation\Exception\InvalidResourceException', sprintf('Unable to load "%s".', $resource));
  56. $loader->load($resource, 'en', 'domain1');
  57. }
  58. }