added the possibility to ignore the filesystem constructor argument (closes #1104)
authorFabien Potencier <fabien.potencier@gmail.com>
Mon, 27 May 2013 06:08:37 +0000 (08:08 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Mon, 27 May 2013 06:08:37 +0000 (08:08 +0200)
lib/Twig/Loader/Filesystem.php
test/Twig/Tests/Loader/FilesystemTest.php

index 84a5e03..f9211cb 100644 (file)
@@ -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);
+        }
     }
 
     /**
index 798e994..c3f6ece 100644 (file)
@@ -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());