Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Feb 8, 2019
1 parent b58eb07 commit 8f4ee50
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
31 changes: 31 additions & 0 deletions tests/Phug/Adapter/FileAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,37 @@ public function testCacheErrorTrace()
static::emptyDirectory($directory);
}

/**
* @covers \Phug\Renderer\Adapter\FileAdapter::<public>
* @covers \Phug\Renderer\Adapter\FileAdapter::cache
* @covers \Phug\Renderer\Adapter\FileAdapter::cacheFileContents
*/
public function testCacheRenderString()
{
$directory = sys_get_temp_dir().'/pug'.mt_rand(0, 99999999);
static::emptyDirectory($directory);
if (!file_exists($directory)) {
mkdir($directory);
}
$options = [
'debug' => true,
'cache_dir' => $directory,
];
$lastError = null;
$renderer = new Renderer($options);


$html = $renderer->render('p Hello');

self::assertSame('<p>Hello</p>', $html);

$html = $renderer->render('div Bye');

self::assertSame('<div>Bye</div>', $html);

static::emptyDirectory($directory);
}

/**
* @covers \Phug\Renderer\Partial\FileSystemTrait::scanDirectory
* @covers \Phug\Renderer\Partial\CacheTrait::getCacheAdapter
Expand Down
24 changes: 22 additions & 2 deletions tests/Phug/RendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,8 @@ public function testExtendsUndefinedCall()
}

$renderer = new Renderer([
'pretty' => true,
'color_support' => false,
'pretty' => true,
]);

$renderer->renderFile(__DIR__.'/../call-undefined/extends-call-undefined.pug');
Expand All @@ -1037,7 +1038,8 @@ public function testUndefinedCallInBlock()
}

$renderer = new Renderer([
'pretty' => true,
'color_support' => false,
'pretty' => true,
]);

$renderer->renderFile(__DIR__.'/../call-undefined/call-undefined-in-block.pug');
Expand Down Expand Up @@ -1119,4 +1121,22 @@ public function testConsecutiveRenders()

$this->assertSameLines(file_get_contents(__DIR__.'/../cases/comments.html'), $html);
}

/**
* @throws RendererException
*/
public function testConsecutiveStringRenders()
{
$renderer = new Renderer([
'debug' => false,
]);

$html = $renderer->render('p Hello');

$this->assertSameLines('<p>Hello</p>', $html);

$html = $renderer->render('div Bye');

$this->assertSameLines('<div>Bye</div>', $html);
}
}

0 comments on commit 8f4ee50

Please sign in to comment.