From 8f68e663acdc1d030406571ea90642748fb2f6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 6 Jan 2017 10:12:54 +0100 Subject: [PATCH] Allow twig/twig 2.0 (#74) Twig 2.0 is out, let's allow it! --- composer.json | 2 +- test/Bridge/Twig/Extension/EnumExtensionTest.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ed8e463..525f110 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "symfony/framework-bundle": "^2.7 || ^3.0", "symfony/twig-bundle": "^2.7 || ^3.0", "symfony/validator": "^2.7 || ^3.0", - "twig/twig": "^1.24" + "twig/twig": "^1.24 || ^2.0" }, "suggest": { "symfony/form": "To use enum form type", diff --git a/test/Bridge/Twig/Extension/EnumExtensionTest.php b/test/Bridge/Twig/Extension/EnumExtensionTest.php index 3baa3d2..394e6a8 100644 --- a/test/Bridge/Twig/Extension/EnumExtensionTest.php +++ b/test/Bridge/Twig/Extension/EnumExtensionTest.php @@ -33,11 +33,17 @@ protected function setUp() public function testEnvironment() { - $twig = new \Twig_Environment(); + $twig = new \Twig_Environment($this->createMock(\Twig_LoaderInterface::class)); $twig->addExtension($this->extension); - $this->assertTrue($twig->hasExtension('greg0ire_enum')); $this->assertInstanceOf(\Twig_SimpleFilter::class, $twig->getFilter('enum_label')); + + if (version_compare(\Twig_Environment::VERSION, '1.26.0') === -1) { + $this->assertTrue($twig->hasExtension('greg0ire_enum')); + + return; + } + $this->assertTrue($twig->hasExtension(EnumExtension::class)); } /**