IcuResFileLoaderTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\IcuResFileLoader;
  12. use Symfony\Component\Config\Resource\DirectoryResource;
  13. /**
  14. * @requires extension intl
  15. */
  16. class IcuResFileLoaderTest extends LocalizedTestCase
  17. {
  18. public function testLoad()
  19. {
  20. // resource is build using genrb command
  21. $loader = new IcuResFileLoader();
  22. $resource = __DIR__.'/../fixtures/resourcebundle/res';
  23. $catalogue = $loader->load($resource, 'en', 'domain1');
  24. $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
  25. $this->assertEquals('en', $catalogue->getLocale());
  26. $this->assertEquals(array(new DirectoryResource($resource)), $catalogue->getResources());
  27. }
  28. /**
  29. * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
  30. */
  31. public function testLoadNonExistingResource()
  32. {
  33. $loader = new IcuResFileLoader();
  34. $loader->load(__DIR__.'/../fixtures/non-existing.txt', 'en', 'domain1');
  35. }
  36. /**
  37. * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException
  38. */
  39. public function testLoadInvalidResource()
  40. {
  41. $loader = new IcuResFileLoader();
  42. $loader->load(__DIR__.'/../fixtures/resourcebundle/corrupted', 'en', 'domain1');
  43. }
  44. }