This commit is contained in:
bzick 2016-06-09 16:00:18 +03:00
parent a910b71a81
commit 1e724e4c70
3 changed files with 23 additions and 10 deletions

View File

@ -998,12 +998,7 @@ class Fenom
{ {
$options |= $this->_options; $options |= $this->_options;
if (is_array($template)) { if (is_array($template)) {
if(count($template) === 1) { $key = $options . "@" . implode(",", $template);
$template = current($template);
$key = $options . "@" . $template;
} else {
$key = $options . "@" . implode(",", $template);
}
} else { } else {
$key = $options . "@" . $template; $key = $options . "@" . $template;
} }

View File

@ -48,15 +48,20 @@ class TestCase extends \PHPUnit_Framework_TestCase
); );
} }
public function getCompilePath()
{
return FENOM_RESOURCES . '/compile';
}
public function setUp() public function setUp()
{ {
if (!file_exists(FENOM_RESOURCES . '/compile')) { if (!file_exists($this->getCompilePath())) {
mkdir(FENOM_RESOURCES . '/compile', 0777, true); mkdir($this->getCompilePath(), 0777, true);
} else { } else {
FS::clean(FENOM_RESOURCES . '/compile/'); FS::clean($this->getCompilePath());
} }
$this->fenom = Fenom::factory(FENOM_RESOURCES . '/' . $this->template_path, FENOM_RESOURCES . '/compile'); $this->fenom = Fenom::factory(FENOM_RESOURCES . '/' . $this->template_path, $this->getCompilePath());
$this->fenom->addProvider('persist', new Provider(FENOM_RESOURCES . '/provider')); $this->fenom->addProvider('persist', new Provider(FENOM_RESOURCES . '/provider'));
$this->fenom->addModifier('dots', __CLASS__ . '::dots'); $this->fenom->addModifier('dots', __CLASS__ . '::dots');
$this->fenom->addModifier('concat', __CLASS__ . '::concat'); $this->fenom->addModifier('concat', __CLASS__ . '::concat');

View File

@ -116,6 +116,19 @@ class FenomTest extends \Fenom\TestCase
$this->assertSame("Custom template (new)", $this->fenom->fetch('custom.tpl', array())); $this->assertSame("Custom template (new)", $this->fenom->fetch('custom.tpl', array()));
} }
/**
* @group dev
*/
public function testCompileIdAndName()
{
$this->fenom->setCompileId("iddqd.");
$this->tpl('custom.tpl', 'Custom template');
$this->assertSame("Custom template", $this->fenom->fetch('custom.tpl', array()));
$compile_name = $this->fenom->getCompileName('custom.tpl');
$this->assertFileExists($this->getCompilePath().'/'.$compile_name);
$this->assertStringStartsWith('iddqd.', $compile_name);
}
public function testSetModifier() public function testSetModifier()
{ {
$this->fenom->addModifier("mymod", "myMod"); $this->fenom->addModifier("mymod", "myMod");