Esempio n. 1
0
 public function testConfigLoad()
 {
     $container = new ContainerBuilder();
     $loader = new TwigExtension();
     $loader->configLoad(array(), $container);
     $this->assertEquals('Symfony\\Bundle\\TwigBundle\\Environment', $container->getParameter('twig.class'), '->configLoad() loads the twig.xml file if not already loaded');
     $loader->configLoad(array('charset' => 'ISO-8859-1'), $container);
     $options = $container->getParameter('twig.options');
     $this->assertEquals('ISO-8859-1', $options['charset'], '->configLoad() overrides existing configuration options');
     $this->assertEquals('%kernel.debug%', $options['debug'], '->configLoad() merges the new values with the old ones');
 }
 public function testConfigExtensions()
 {
     // XML
     $container = new ContainerBuilder();
     $container->register('foo', 'stdClass');
     $loader = new TwigExtension();
     $loader->configLoad(array(array('extensions' => array(array('id' => 'foo')))), $container);
     $config = $container->getDefinition('foo');
     $this->assertEquals(array('twig.extension'), array_keys($config->getTags()));
     // YAML, PHP
     $container = new ContainerBuilder();
     $container->register('foo', 'stdClass');
     $loader = new TwigExtension();
     $loader->configLoad(array(array('extensions' => array('foo'))), $container);
     $config = $container->getDefinition('foo');
     $this->assertEquals(array('twig.extension'), array_keys($config->getTags()));
 }
 public function testConfigGlobals()
 {
     // XML
     $container = new ContainerBuilder();
     $loader = new TwigExtension();
     $loader->configLoad(array('global' => array(array('key' => 'foo', 'id' => 'bar'))), $container);
     $config = $container->getDefinition('twig')->getMethodCalls();
     $this->assertEquals('foo', $config[0][1][0]);
     $this->assertEquals('bar', (string) $config[0][1][1]);
     // YAML, PHP
     $container = new ContainerBuilder();
     $loader = new TwigExtension();
     $loader->configLoad(array('globals' => array('foo' => 'bar')), $container);
     $config = $container->getDefinition('twig')->getMethodCalls();
     $this->assertEquals('foo', $config[0][1][0]);
     $this->assertEquals('bar', (string) $config[0][1][1]);
 }