2010-03-18 07:48:03 +00:00
< ? php
/*
2010-04-25 16:06:54 +01:00
* This file is part of the Symfony package .
2010-03-18 07:48:03 +00:00
* ( c ) Fabien Potencier < fabien . potencier @ symfony - project . com >
2010-04-07 02:07:59 +01:00
*
2010-03-18 07:48:03 +00:00
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
namespace Symfony\Tests\Components\DependencyInjection\Loader ;
2010-06-28 08:31:54 +01:00
require_once __DIR__ . '/../Fixtures/includes/ProjectExtension.php' ;
2010-03-18 07:48:03 +00:00
2010-06-07 06:57:01 +01:00
use Symfony\Components\DependencyInjection\BuilderConfiguration ;
2010-03-18 07:48:03 +00:00
class LoaderExtensionTest extends \PHPUnit_Framework_TestCase
{
2010-06-27 17:28:29 +01:00
/**
* @ covers Symfony\Components\DependencyInjection\Loader\LoaderExtension :: load
*/
2010-05-06 12:25:53 +01:00
public function testLoad ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$extension = new \ProjectExtension ();
2010-05-07 15:09:11 +01:00
try {
2010-06-07 06:57:01 +01:00
$extension -> load ( 'foo' , array (), new BuilderConfiguration ());
2010-05-06 12:25:53 +01:00
$this -> fail ( '->load() throws an InvalidArgumentException if the tag does not exist' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\InvalidArgumentException' , $e , '->load() throws an InvalidArgumentException if the tag does not exist' );
2010-06-16 14:45:20 +01:00
$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' );
2010-05-06 12:25:53 +01:00
}
2010-03-18 07:48:03 +00:00
2010-07-09 15:28:06 +01:00
$extension -> load ( 'bar' , array ( 'foo' => 'bar' ), $config = new BuilderConfiguration ());
2010-06-27 17:28:29 +01:00
$this -> assertEquals ( array ( 'project.parameter.bar' => 'bar' , 'project.parameter.foo' => 'bar' ), $config -> getParameterBag () -> all (), '->load() calls the method tied to the given tag' );
2010-05-06 12:25:53 +01:00
}
2010-03-18 07:48:03 +00:00
}