Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
Added option to override template location in AbstractWidgetTestCase (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 authored and OskarStark committed Aug 22, 2016
1 parent 86e24d0 commit 5a9160c
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Test/AbstractWidgetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ protected function setUp()
* @return \Twig_Environment
*/
protected function getEnvironment()
{
$loader = new StubFilesystemLoader($this->getTemplatePaths());

$environment = new \Twig_Environment($loader, array(
'strict_variables' => true,
));
$environment->addExtension(new TranslationExtension(new StubTranslator()));
$environment->addExtension($this->extension);

return $environment;
}

/**
* Returns a list of template paths.
*
* @return string[]
*/
protected function getTemplatePaths()
{
// this is an workaround for different composer requirements and different TwigBridge installation directories
$twigPaths = array_filter(array(
Expand All @@ -79,15 +97,7 @@ protected function getEnvironment()

$twigPaths[] = __DIR__.'/../Resources/views/Form';

$loader = new StubFilesystemLoader($twigPaths);

$environment = new \Twig_Environment($loader, array(
'strict_variables' => true,
));
$environment->addExtension(new TranslationExtension(new StubTranslator()));
$environment->addExtension($this->extension);

return $environment;
return $twigPaths;
}

/**
Expand Down

0 comments on commit 5a9160c

Please sign in to comment.