diff --git a/composer.json b/composer.json index 115adbfc16..7a1c557dad 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.9", "doctrine/common": "~2.3", - "twig/twig": "~1.18", + "twig/twig": "~1.20|~2.0", "psr/log": "~1.0" }, "replace": { diff --git a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php index c3ebd51bbc..e598ae104a 100644 --- a/src/Symfony/Bridge/Twig/Node/FormThemeNode.php +++ b/src/Symfony/Bridge/Twig/Node/FormThemeNode.php @@ -16,7 +16,7 @@ namespace Symfony\Bridge\Twig\Node; */ class FormThemeNode extends \Twig_Node { - public function __construct(\Twig_NodeInterface $form, \Twig_NodeInterface $resources, $lineno, $tag = null) + public function __construct(\Twig_Node $form, \Twig_Node $resources, $lineno, $tag = null) { parent::__construct(array('form' => $form, 'resources' => $resources), array(), $lineno, $tag); } diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index 71823a1b78..af85d8f185 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -16,7 +16,7 @@ namespace Symfony\Bridge\Twig\Node; */ class TransNode extends \Twig_Node { - public function __construct(\Twig_NodeInterface $body, \Twig_NodeInterface $domain = null, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, \Twig_Node_Expression $locale = null, $lineno = 0, $tag = null) + public function __construct(\Twig_Node $body, \Twig_Node $domain = null, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, \Twig_Node_Expression $locale = null, $lineno = 0, $tag = null) { parent::__construct(array('count' => $count, 'body' => $body, 'domain' => $domain, 'vars' => $vars, 'locale' => $locale), array(), $lineno, $tag); } @@ -83,7 +83,7 @@ class TransNode extends \Twig_Node $compiler->raw(");\n"); } - protected function compileString(\Twig_NodeInterface $body, \Twig_Node_Expression_Array $vars, $ignoreStrictCheck = false) + protected function compileString(\Twig_Node $body, \Twig_Node_Expression_Array $vars, $ignoreStrictCheck = false) { if ($body instanceof \Twig_Node_Expression_Constant) { $msg = $body->getAttribute('value'); diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index 841eb0dca2..c923df9944 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -19,7 +19,7 @@ use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; * * @author Fabien Potencier */ -class TranslationDefaultDomainNodeVisitor implements \Twig_NodeVisitorInterface +class TranslationDefaultDomainNodeVisitor extends \Twig_BaseNodeVisitor { /** * @var Scope @@ -37,7 +37,7 @@ class TranslationDefaultDomainNodeVisitor implements \Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) + protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env) { if ($node instanceof \Twig_Node_Block || $node instanceof \Twig_Node_Module) { $this->scope = $this->scope->enter(); @@ -89,7 +89,7 @@ class TranslationDefaultDomainNodeVisitor implements \Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) + protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env) { if ($node instanceof TransDefaultDomainNode) { return false; diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index 0ce1f3d92a..4426a9d3b6 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -18,7 +18,7 @@ use Symfony\Bridge\Twig\Node\TransNode; * * @author Fabien Potencier */ -class TranslationNodeVisitor implements \Twig_NodeVisitorInterface +class TranslationNodeVisitor extends \Twig_BaseNodeVisitor { const UNDEFINED_DOMAIN = '_undefined'; @@ -45,7 +45,7 @@ class TranslationNodeVisitor implements \Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) + protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env) { if (!$this->enabled) { return $node; @@ -85,7 +85,7 @@ class TranslationNodeVisitor implements \Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) + protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env) { return $node; } diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index a0828b3800..1c428fdbc7 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -203,7 +203,7 @@ {# Labels #} {%- block form_label -%} - {% if label is not sameas(false) -%} + {% if label is not same as(false) -%} {% if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif %} diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php index cd0bbdf0ec..1c1ac645c8 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php @@ -20,7 +20,7 @@ class RoutingExtensionTest extends \PHPUnit_Framework_TestCase */ public function testEscaping($template, $mustBeEscaped) { - $twig = new \Twig_Environment(null, array('debug' => true, 'cache' => false, 'autoescape' => true, 'optimizations' => 0)); + $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0)); $twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'))); $nodes = $twig->parse($twig->tokenize($template)); diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 5f8ae11211..0fadfdabc6 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -41,7 +41,7 @@ class FormThemeTest extends \PHPUnit_Framework_TestCase $node = new FormThemeNode($form, $resources, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 60ef9edfb9..05b28c947d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -23,7 +23,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( @@ -46,7 +46,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_widget', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( @@ -66,7 +66,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( @@ -86,7 +86,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -108,7 +108,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -129,7 +129,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( @@ -153,7 +153,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -182,7 +182,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertEquals( sprintf( @@ -210,7 +210,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. @@ -247,7 +247,7 @@ class SearchAndRenderBlockNodeTest extends \PHPUnit_Framework_TestCase $node = new SearchAndRenderBlockNode('form_label', $arguments, 0); - $compiler = new \Twig_Compiler(new \Twig_Environment()); + $compiler = new \Twig_Compiler(new \Twig_Environment($this->getMock('Twig_LoaderInterface'))); // "label" => null must not be included in the output! // Otherwise the default label is overwritten with null. diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index df5eb559d8..4399ca7728 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -24,7 +24,7 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase $vars = new \Twig_Node_Expression_Name('foo', 0); $node = new TransNode($body, null, null, $vars); - $env = new \Twig_Environment(null, array('strict_variables' => true)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)); $compiler = new \Twig_Compiler($env); $this->assertEquals( @@ -47,6 +47,10 @@ class TransNodeTest extends \PHPUnit_Framework_TestCase protected function getVariableGetterWithStrictCheck($name) { + if (version_compare(\Twig_Environment::VERSION, '2.0.0-DEV', '>=')) { + return sprintf('(isset($context["%s"]) || array_key_exists("%s", $context) ? $context["%s"] : $this->notFound("%s", 0))', $name, $name, $name, $name); + } + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index 837844e861..f9cf08bc28 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -22,7 +22,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas /** @dataProvider getDefaultDomainAssignmentTestData */ public function testDefaultDomainAssignment(\Twig_Node $node) { - $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag @@ -48,7 +48,7 @@ class TranslationDefaultDomainNodeVisitorTest extends \PHPUnit_Framework_TestCas /** @dataProvider getDefaultDomainAssignmentTestData */ public function testNewModuleWithoutDefaultDomainTag(\Twig_Node $node) { - $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationDefaultDomainNodeVisitor(); // visit trans_default_domain tag diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 0f3ec40091..16736031e0 100644 --- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -18,7 +18,7 @@ class TranslationNodeVisitorTest extends \PHPUnit_Framework_TestCase /** @dataProvider getMessagesExtractionTestData */ public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages) { - $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $visitor = new TranslationNodeVisitor(); $visitor->enable(); $visitor->enterNode($node, $env); diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php index 69c46fd220..2986cd1258 100644 --- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php @@ -21,7 +21,7 @@ class FormThemeTokenParserTest extends \PHPUnit_Framework_TestCase */ public function testCompile($source, $expected) { - $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $env->addTokenParser(new FormThemeTokenParser()); $stream = $env->tokenize($source); $parser = new \Twig_Parser($env); diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 610d5a6068..5e7c4ce521 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -22,7 +22,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase */ public function testExtract($template, $messages) { - $loader = new \Twig_Loader_Array(array()); + $loader = $this->getMock('Twig_LoaderInterface'); $twig = new \Twig_Environment($loader, array( 'strict_variables' => true, 'debug' => true, @@ -78,7 +78,7 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase */ public function testExtractSyntaxError($resources) { - $twig = new \Twig_Environment(new \Twig_Loader_Array(array())); + $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface'))); $extractor = new TwigExtractor($twig); diff --git a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php index 244d676e3c..daf87824e7 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/FormThemeTokenParser.php @@ -25,7 +25,7 @@ class FormThemeTokenParser extends \Twig_TokenParser * * @param \Twig_Token $token A Twig_Token instance * - * @return \Twig_NodeInterface A Twig_NodeInterface instance + * @return \Twig_Node A Twig_Node instance */ public function parse(\Twig_Token $token) { diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index e4757d8b9d..7ea1a2c414 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -25,7 +25,7 @@ class TransChoiceTokenParser extends TransTokenParser * * @param \Twig_Token $token A Twig_Token instance * - * @return \Twig_NodeInterface A Twig_NodeInterface instance + * @return \Twig_Node A Twig_Node instance * * @throws \Twig_Error_Syntax */ diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php index 0a0ed55b55..09832ea972 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php @@ -25,7 +25,7 @@ class TransDefaultDomainTokenParser extends \Twig_TokenParser * * @param \Twig_Token $token A Twig_Token instance * - * @return \Twig_NodeInterface A Twig_NodeInterface instance + * @return \Twig_Node A Twig_Node instance */ public function parse(\Twig_Token $token) { diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index 96e420e5ce..06472d0b42 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -25,7 +25,7 @@ class TransTokenParser extends \Twig_TokenParser * * @param \Twig_Token $token A Twig_Token instance * - * @return \Twig_NodeInterface A Twig_NodeInterface instance + * @return \Twig_Node A Twig_Node instance * * @throws \Twig_Error_Syntax */ diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index f2655f3970..74939001f5 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=5.3.9", - "twig/twig": "~1.18" + "twig/twig": "~1.20|~2.0" }, "require-dev": { "symfony/phpunit-bridge": "~2.7", diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php index 2fe31ec0b9..1757cfee96 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php @@ -25,7 +25,7 @@ class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container->expects($this->once()) ->method('get') - ->will($this->returnValue($this->getMock('\Twig_Environment'))) + ->will($this->returnValue($this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock())) ; $renderer = new ContainerAwareHIncludeFragmentRenderer($container); $renderer->render('/', Request::create('/')); diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 9c93440aa7..881031d020 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -38,7 +38,7 @@ "symfony/yaml": "~2.0,>=2.0.5", "symfony/expression-language": "~2.6", "doctrine/doctrine-bundle": "~1.2", - "twig/twig": "~1.12", + "twig/twig": "~1.20|~2.0", "ircmaxell/password-compat": "~1.0" }, "autoload": { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php index e67dd1cc07..e3d0a72a6c 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php @@ -25,7 +25,7 @@ class LegacyRenderTokenParserTest extends TestCase */ public function testCompile($source, $expected) { - $env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); + $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0)); $env->addTokenParser(new RenderTokenParser()); $stream = $env->tokenize($source); $parser = new \Twig_Parser($env); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index 1ed32ca676..25b5c82f6c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -23,7 +23,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase public function testEmptyToken($token) { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() @@ -47,7 +47,7 @@ class ProfilerControllerTest extends \PHPUnit_Framework_TestCase public function testReturns404onTokenNotFound() { $urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); - $twig = $this->getMock('Twig_Environment'); + $twig = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $profiler = $this ->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler') ->disableOriginalConstructor() diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php index 132315fd23..5eaa95c0a3 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/DependencyInjection/WebProfilerExtensionTest.php @@ -53,6 +53,8 @@ class WebProfilerExtensionTest extends TestCase $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request'); $this->container->register('router', $this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')); $this->container->register('twig', 'Twig_Environment'); + $this->container->register('twig_loader', 'Twig_Loader_Array')->addArgument(array()); + $this->container->register('twig', 'Twig_Environment')->addArgument(new Reference('twig_loader')); $this->container->setParameter('kernel.bundles', array()); $this->container->setParameter('kernel.cache_dir', __DIR__); $this->container->setParameter('kernel.debug', false); diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php index 4638ee36e9..5c8a3becb8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php @@ -138,7 +138,7 @@ class TemplateManagerTest extends TestCase protected function mockTwigEnvironment() { - $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->getMock(); + $this->twigEnvironment = $this->getMockBuilder('Twig_Environment')->disableOriginalConstructor()->getMock(); $this->twigEnvironment->expects($this->any()) ->method('loadTemplate')