Improve prod filesystem loader test coverage.

This commit is contained in:
Justin Hileman
2017-07-03 00:17:31 -07:00
parent 7434e97df5
commit 933554098a
2 changed files with 46 additions and 0 deletions
@@ -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);
}
}
@@ -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();
}
}