IniFileLoaderTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. require_once __DIR__.'/../../../bootstrap.php';
  11. use Symfony\Components\DependencyInjection\Builder;
  12. use Symfony\Components\DependencyInjection\Loader\IniFileLoader;
  13. class IniLoaderTest extends \PHPUnit_Framework_TestCase
  14. {
  15. static protected $fixturesPath;
  16. static public function setUpBeforeClass()
  17. {
  18. self::$fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/');
  19. }
  20. public function testLoader()
  21. {
  22. $loader = new IniFileLoader(self::$fixturesPath.'/ini');
  23. $config = $loader->load('parameters.ini');
  24. $this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $config->getParameters(), '->load() takes a single file name as its first argument');
  25. try
  26. {
  27. $loader->load('foo.ini');
  28. $this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
  29. }
  30. catch (\InvalidArgumentException $e)
  31. {
  32. }
  33. try
  34. {
  35. @$loader->load('nonvalid.ini');
  36. $this->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
  37. }
  38. catch (\InvalidArgumentException $e)
  39. {
  40. }
  41. }
  42. }