Browse code

added the possibility to ignore the filesystem constructor argument (closes #1104)

Fabien Potencier authored on 27/05/2013 06:08:37
Showing 2 changed files
... ...
@@ -24,9 +24,11 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
24 24
      *
25 25
      * @param string|array $paths A path or an array of paths where to look for templates
26 26
      */
27
-    public function __construct($paths)
27
+    public function __construct($paths = array())
28 28
     {
29
-        $this->setPaths($paths);
29
+        if ($paths) {
30
+            $this->setPaths($paths);
31
+        }
30 32
     }
31 33
 
32 34
     /**
... ...
@@ -80,6 +80,12 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
80 80
         $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
81 81
     }
82 82
 
83
+    public function testEmptyConstructor()
84
+    {
85
+        $loader = new Twig_Loader_Filesystem();
86
+        $this->assertEquals(array(), $loader->getPaths());
87
+    }
88
+
83 89
     public function testGetNamespaces()
84 90
     {
85 91
         $loader = new Twig_Loader_Filesystem(sys_get_temp_dir());