Skip to content

Commit

Permalink
Tests++
Browse files Browse the repository at this point in the history
  • Loading branch information
bzick committed Jun 9, 2016
1 parent a910b71 commit 1e724e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/Fenom.php
Expand Up @@ -998,12 +998,7 @@ public function getTemplate($template, $options = 0)
{
$options |= $this->_options;
if (is_array($template)) {
if(count($template) === 1) {
$template = current($template);
$key = $options . "@" . $template;
} else {
$key = $options . "@" . implode(",", $template);
}
$key = $options . "@" . implode(",", $template);
} else {
$key = $options . "@" . $template;
}
Expand Down
13 changes: 9 additions & 4 deletions tests/TestCase.php
Expand Up @@ -48,15 +48,20 @@ public static function getVars()
);
}

public function getCompilePath()
{
return FENOM_RESOURCES . '/compile';
}

public function setUp()
{
if (!file_exists(FENOM_RESOURCES . '/compile')) {
mkdir(FENOM_RESOURCES . '/compile', 0777, true);
if (!file_exists($this->getCompilePath())) {
mkdir($this->getCompilePath(), 0777, true);
} 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->addModifier('dots', __CLASS__ . '::dots');
$this->fenom->addModifier('concat', __CLASS__ . '::concat');
Expand Down
13 changes: 13 additions & 0 deletions tests/cases/FenomTest.php
Expand Up @@ -116,6 +116,19 @@ public function testForceCompile()
$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()
{
$this->fenom->addModifier("mymod", "myMod");
Expand Down

0 comments on commit 1e724e4

Please sign in to comment.