IniFileLoaderTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Symfony\Tests\Components\DependencyInjection\Loader;
  10. use Symfony\Components\DependencyInjection\Builder;
  11. use Symfony\Components\DependencyInjection\Loader\IniFileLoader;
  12. class IniLoaderTest extends \PHPUnit_Framework_TestCase
  13. {
  14. static protected $fixturesPath;
  15. static public function setUpBeforeClass()
  16. {
  17. self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/');
  18. }
  19. public function testLoader()
  20. {
  21. $loader = new IniFileLoader(self::$fixturesPath.'/ini');
  22. $config = $loader->load('parameters.ini');
  23. $this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $config->getParameters(), '->load() takes a single file name as its first argument');
  24. try
  25. {
  26. $loader->load('foo.ini');
  27. $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
  28. }
  29. catch (\InvalidArgumentException $e)
  30. {
  31. }
  32. try
  33. {
  34. @$loader->load('nonvalid.ini');
  35. $this->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
  36. }
  37. catch (\InvalidArgumentException $e)
  38. {
  39. }
  40. }
  41. }