IniLoaderTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. require_once __DIR__.'/../../../../bootstrap.php';
  10. use Symfony\Components\DependencyInjection\Builder;
  11. use Symfony\Components\DependencyInjection\Loader\IniFileLoader;
  12. $t = new LimeTest(3);
  13. $fixturesPath = realpath(__DIR__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/');
  14. $loader = new IniFileLoader($fixturesPath.'/ini');
  15. $config = $loader->load('parameters.ini');
  16. $t->is($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%'), '->load() takes a single file name as its first argument');
  17. try
  18. {
  19. $loader->load('foo.ini');
  20. $t->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
  21. }
  22. catch (InvalidArgumentException $e)
  23. {
  24. $t->pass('->load() throws an InvalidArgumentException if the loaded file does not exist');
  25. }
  26. try
  27. {
  28. @$loader->load('nonvalid.ini');
  29. $t->fail('->load() throws an InvalidArgumentException if the loaded file is not parseable');
  30. }
  31. catch (InvalidArgumentException $e)
  32. {
  33. $t->pass('->load() throws an InvalidArgumentException if the loaded file is not parseable');
  34. }