ExtensionTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.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\DependencyInjection\Extension;
  11. require_once __DIR__.'/../Fixtures/includes/ProjectExtension.php';
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. class ExtensionTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @covers Symfony\Component\DependencyInjection\Extension\Extension::load
  17. */
  18. public function testLoad()
  19. {
  20. $extension = new \ProjectExtension();
  21. try {
  22. $extension->load('foo', array(), new ContainerBuilder());
  23. $this->fail('->load() throws an InvalidArgumentException if the tag does not exist');
  24. } catch (\Exception $e) {
  25. $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag does not exist');
  26. $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');
  27. }
  28. $extension->load('bar', array('foo' => 'bar'), $config = new ContainerBuilder());
  29. $this->assertEquals(array('project.parameter.bar' => 'bar', 'project.parameter.foo' => 'bar'), $config->getParameterBag()->all(), '->load() calls the method tied to the given tag');
  30. }
  31. }