菜谱项目

IniFileLoaderTest.php 1.6KB

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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Translation\Loader\IniFileLoader;
  13. use Symfony\Component\Config\Resource\FileResource;
  14. class IniFileLoaderTest extends TestCase
  15. {
  16. public function testLoad()
  17. {
  18. $loader = new IniFileLoader();
  19. $resource = __DIR__.'/../fixtures/resources.ini';
  20. $catalogue = $loader->load($resource, 'en', 'domain1');
  21. $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
  22. $this->assertEquals('en', $catalogue->getLocale());
  23. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
  24. }
  25. public function testLoadDoesNothingIfEmpty()
  26. {
  27. $loader = new IniFileLoader();
  28. $resource = __DIR__.'/../fixtures/empty.ini';
  29. $catalogue = $loader->load($resource, 'en', 'domain1');
  30. $this->assertEquals(array(), $catalogue->all('domain1'));
  31. $this->assertEquals('en', $catalogue->getLocale());
  32. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
  33. }
  34. /**
  35. * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
  36. */
  37. public function testLoadNonExistingResource()
  38. {
  39. $loader = new IniFileLoader();
  40. $resource = __DIR__.'/../fixtures/non-existing.ini';
  41. $loader->load($resource, 'en', 'domain1');
  42. }
  43. }