No Description

IcuResFileLoaderTest.php 1.7KB

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