PhpFileLoaderTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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\Tests\Component\Translation\Loader;
  11. use Symfony\Component\Translation\Loader\PhpFileLoader;
  12. use Symfony\Component\Config\Resource\FileResource;
  13. class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testLoad()
  16. {
  17. $loader = new PhpFileLoader();
  18. $resource = __DIR__.'/../fixtures/resources.php';
  19. $catalogue = $loader->load($resource, 'en', 'domain1');
  20. $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1'));
  21. $this->assertEquals('en', $catalogue->getLocale());
  22. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
  23. }
  24. /**
  25. * @expectedException \InvalidArgumentException
  26. */
  27. public function testLoadThrowsAnExceptionIfFileNotLocal()
  28. {
  29. $loader = new PhpFileLoader();
  30. $resource = 'http://example.com/resources.php';
  31. $loader->load($resource, 'en', 'domain1');
  32. }
  33. }