Add support for runtime loaders to IntegrationTestCase

This commit is contained in:
Edi Modrić
2017-06-09 10:04:55 +02:00
parent b3cb3d22d7
commit ff96b34a62
+12
View File
@@ -24,6 +24,14 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
*/ */
abstract protected function getFixturesDir(); abstract protected function getFixturesDir();
/**
* @return Twig_RuntimeLoaderInterface[]
*/
protected function getRuntimeLoaders()
{
return array();
}
/** /**
* @return Twig_ExtensionInterface[] * @return Twig_ExtensionInterface[]
*/ */
@@ -143,6 +151,10 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
), $match[2] ? eval($match[2].';') : array()); ), $match[2] ? eval($match[2].';') : array());
$twig = new Twig_Environment($loader, $config); $twig = new Twig_Environment($loader, $config);
$twig->addGlobal('global', 'global'); $twig->addGlobal('global', 'global');
foreach ($this->getRuntimeLoaders() as $runtimeLoader) {
$twig->addRuntimeLoader($runtimeLoader);
}
foreach ($this->getExtensions() as $extension) { foreach ($this->getExtensions() as $extension) {
$twig->addExtension($extension); $twig->addExtension($extension);
} }