LoaderExtensionTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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. class LoaderExtensionTest extends \PHPUnit_Framework_TestCase
  12. {
  13. public function testLoad()
  14. {
  15. $extension = new \ProjectExtension();
  16. try
  17. {
  18. $extension->load('foo', array());
  19. $this->fail('->load() throws an InvalidArgumentException if the tag does not exist');
  20. }
  21. catch (\Exception $e)
  22. {
  23. $this->assertType('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag does not exist');
  24. $this->assertEquals('The tag "foo" is not defined in the "http://www.example.com/schema/project" extension.', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag does not exist');
  25. }
  26. $config = $extension->load('bar', array('foo' => 'bar'));
  27. $this->assertEquals(array('project.parameter.bar' => 'bar'), $config->getParameters(), '->load() calls the method tied to the given tag');
  28. }
  29. }