ExtensionTest.php 1.5 KB

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