From f6c00587f8b2d6e680d09fd6015fa521f9c72327 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 27 May 2013 08:08:37 +0200 Subject: [PATCH] added the possibility to ignore the filesystem constructor argument (closes #1104) --- lib/Twig/Loader/Filesystem.php | 6 ++++-- test/Twig/Tests/Loader/FilesystemTest.php | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 84a5e03..f9211cb 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -24,9 +24,11 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI * * @param string|array $paths A path or an array of paths where to look for templates */ - public function __construct($paths) + public function __construct($paths = array()) { - $this->setPaths($paths); + if ($paths) { + $this->setPaths($paths); + } } /** diff --git a/test/Twig/Tests/Loader/FilesystemTest.php b/test/Twig/Tests/Loader/FilesystemTest.php index 798e994..c3f6ece 100644 --- a/test/Twig/Tests/Loader/FilesystemTest.php +++ b/test/Twig/Tests/Loader/FilesystemTest.php @@ -80,6 +80,12 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html')); } + public function testEmptyConstructor() + { + $loader = new Twig_Loader_Filesystem(); + $this->assertEquals(array(), $loader->getPaths()); + } + public function testGetNamespaces() { $loader = new Twig_Loader_Filesystem(sys_get_temp_dir()); -- 1.7.2.5