2010-06-07 08:08:35 +01:00
< ? php
/*
* This file is part of the Symfony package .
*
* ( c ) Fabien Potencier < fabien . potencier @ symfony - project . com >
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
2010-07-09 09:05:26 +01:00
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection ;
2010-06-07 08:08:35 +01:00
2010-07-09 09:05:26 +01:00
use Symfony\Bundle\FrameworkBundle\Tests\TestCase ;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\WebExtension ;
2010-08-20 22:09:55 +01:00
use Symfony\Component\DependencyInjection\ContainerBuilder ;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag ;
2010-06-07 08:08:35 +01:00
class WebExtensionTest extends TestCase
{
2010-06-16 13:19:46 +01:00
public function testConfigLoad ()
2010-06-07 08:08:35 +01:00
{
2010-08-10 20:44:04 +01:00
$container = $this -> getContainer ();
$loader = new WebExtension ();
2010-06-07 08:08:35 +01:00
2010-07-18 11:11:17 +01:00
$loader -> configLoad ( array (), $container );
$this -> assertEquals ( 'Symfony\\Bundle\\FrameworkBundle\\RequestListener' , $container -> getParameter ( 'request_listener.class' ), '->webLoad() loads the web.xml file if not already loaded' );
2010-06-16 13:19:46 +01:00
2010-08-10 14:55:05 +01:00
$container = $this -> getContainer ();
2010-08-10 20:44:04 +01:00
$loader = new WebExtension ();
2010-06-16 13:19:46 +01:00
2010-07-18 11:11:17 +01:00
$loader -> configLoad ( array ( 'profiler' => true ), $container );
$this -> assertEquals ( 'Symfony\\Bundle\\FrameworkBundle\\Profiler' , $container -> getParameter ( 'profiler.class' ), '->configLoad() loads the collectors.xml file if not already loaded' );
2010-06-07 08:08:35 +01:00
}
public function testTemplatingLoad ()
{
2010-08-10 14:55:05 +01:00
$container = $this -> getContainer ();
2010-08-10 20:44:04 +01:00
$loader = new WebExtension ();
2010-06-07 08:08:35 +01:00
2010-07-18 11:11:17 +01:00
$loader -> templatingLoad ( array (), $container );
$this -> assertEquals ( 'Symfony\\Bundle\\FrameworkBundle\\Templating\\Engine' , $container -> getParameter ( 'templating.engine.class' ), '->templatingLoad() loads the templating.xml file if not already loaded' );
2010-06-07 08:08:35 +01:00
}
2010-06-24 09:40:05 +01:00
public function testValidationLoad ()
{
2010-08-10 14:55:05 +01:00
$container = $this -> getContainer ();
2010-08-10 20:44:04 +01:00
$loader = new WebExtension ();
2010-06-24 09:40:05 +01:00
2010-07-18 11:11:17 +01:00
$loader -> configLoad ( array ( 'validation' => array ( 'enabled' => true )), $container );
2010-08-20 22:09:55 +01:00
$this -> assertEquals ( 'Symfony\Component\Validator\Validator' , $container -> getParameter ( 'validator.class' ), '->validationLoad() loads the validation.xml file if not already loaded' );
2010-07-18 11:11:17 +01:00
$this -> assertFalse ( $container -> hasDefinition ( 'validator.mapping.loader.annotation_loader' ), '->validationLoad() doesn\'t load the annotations service unless its needed' );
2010-06-24 09:40:05 +01:00
2010-07-18 11:11:17 +01:00
$loader -> configLoad ( array ( 'validation' => array ( 'enabled' => true , 'annotations' => true )), $container );
$this -> assertTrue ( $container -> hasDefinition ( 'validator.mapping.loader.annotation_loader' ), '->validationLoad() loads the annotations service' );
2010-06-24 09:40:05 +01:00
}
2010-08-10 14:55:05 +01:00
protected function getContainer ()
{
return new ContainerBuilder ( new ParameterBag ( array (
2010-08-10 20:44:04 +01:00
'kernel.bundle_dirs' => array (
'Symfony\\Framework' => __DIR__ . '/../../../Framework' ,
),
'kernel.bundles' => array (
'FrameworkBundle' ,
),
'kernel.debug' => false ,
'kernel.compiled_classes' => array (),
2010-08-10 14:55:05 +01:00
)));
}
2010-06-07 08:08:35 +01:00
}