IcuResFileLoaderTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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\Config\Resource\DirectoryResource;
  12. use Symfony\Component\Translation\Loader\IcuResFileLoader;
  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(['foo' => 'bar'], $catalogue->all('domain1'));
  25. $this->assertEquals('en', $catalogue->getLocale());
  26. $this->assertEquals([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. }