LoaderExtensionTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  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__.'/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php';
  11. use Symfony\Components\DependencyInjection\BuilderConfiguration;
  12. class LoaderExtensionTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testLoad()
  15. {
  16. $extension = new \ProjectExtension();
  17. try {
  18. $extension->load('foo', array(), new BuilderConfiguration());
  19. $this->fail('->load() throws an InvalidArgumentException if the tag does not exist');
  20. } catch (\Exception $e) {
  21. $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag does not exist');
  22. $this->assertEquals('The tag "project:foo" is not defined in the "project" extension.', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag does not exist');
  23. }
  24. $config = $extension->load('bar', array('foo' => 'bar'), new BuilderConfiguration());
  25. $this->assertEquals(array('project.parameter.bar' => 'bar', 'project.parameter.foo' => 'bar'), $config->getParameters(), '->load() calls the method tied to the given tag');
  26. }
  27. }