Эх сурвалжийг харах

Improve prod filesystem loader test coverage.

Justin Hileman 8 жил өмнө
parent
commit
933554098a

+ 21 - 0
test/Mustache/Test/Loader/ProductionFilesystemLoaderTest.php

@@ -79,4 +79,25 @@ class Mustache_Test_Loader_ProductionFilesystemLoaderTest extends PHPUnit_Framew
 
         $loader->load('fake');
     }
+
+    public function testLoadWithDifferentStatProps()
+    {
+        $baseDir = realpath(dirname(__FILE__) . '/../../../fixtures/templates');
+        $noStatLoader = new Mustache_Loader_ProductionFilesystemLoader($baseDir, array('stat_props' => null));
+        $mtimeLoader = new Mustache_Loader_ProductionFilesystemLoader($baseDir, array('stat_props' => array('mtime')));
+        $sizeLoader = new Mustache_Loader_ProductionFilesystemLoader($baseDir, array('stat_props' => array('size')));
+        $bothLoader = new Mustache_Loader_ProductionFilesystemLoader($baseDir, array('stat_props' => array('mtime', 'size')));
+
+        $noStatKey = $noStatLoader->load('one.mustache')->getKey();
+        $mtimeKey = $mtimeLoader->load('one.mustache')->getKey();
+        $sizeKey = $sizeLoader->load('one.mustache')->getKey();
+        $bothKey = $bothLoader->load('one.mustache')->getKey();
+
+        $this->assertNotEquals($noStatKey, $mtimeKey);
+        $this->assertNotEquals($noStatKey, $sizeKey);
+        $this->assertNotEquals($noStatKey, $bothKey);
+        $this->assertNotEquals($mtimeKey, $sizeKey);
+        $this->assertNotEquals($mtimeKey, $bothKey);
+        $this->assertNotEquals($sizeKey, $bothKey);
+    }
 }

+ 25 - 0
test/Mustache/Test/Source/FilesystemSourceTest.php

@@ -0,0 +1,25 @@
+<?php
+
+/*
+ * This file is part of Mustache.php.
+ *
+ * (c) 2010-2017 Justin Hileman
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * @group unit
+ */
+class Mustache_Test_Source_FilesystemSourceTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @expectedException RuntimeException
+     */
+    public function testMissingTemplateThrowsException()
+    {
+        $source = new Mustache_Source_FilesystemSource(dirname(__FILE__) . '/not_a_file.mustache', array('mtime'));
+        $source->getKey();
+    }
+}