summaryrefslogtreecommitdiff
path: root/tests/Unit/Renderer/HtmlEngineTest.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-09-30 11:25:58 +0200
committerGitHub <noreply@github.com>2017-09-30 11:25:58 +0200
commit801c17aa6cef91be988a25a90442be8d2078a70d (patch)
tree7f03157616509fe583b1b0aea6e2d06c53bd9c89 /tests/Unit/Renderer/HtmlEngineTest.php
parente1d44e60e35d126dbd05aefa5f897fad16fbfceb (diff)
parent945fcb079a219fa29e8f6ee1afc3f1c0c5c822cb (diff)
Merge pull request #347 from MyIgel/master
Implemented Container, closes #342
Diffstat (limited to 'tests/Unit/Renderer/HtmlEngineTest.php')
-rw-r--r--tests/Unit/Renderer/HtmlEngineTest.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/Unit/Renderer/HtmlEngineTest.php b/tests/Unit/Renderer/HtmlEngineTest.php
new file mode 100644
index 00000000..0b317b72
--- /dev/null
+++ b/tests/Unit/Renderer/HtmlEngineTest.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Engelsystem\Test\Config;
+
+use Engelsystem\Renderer\HtmlEngine;
+use PHPUnit\Framework\TestCase;
+
+class HtmlEngineTest extends TestCase
+{
+ /** @var string[] */
+ protected $tmpFileNames = [];
+
+ /**
+ * @covers \Engelsystem\Renderer\HtmlEngine::get
+ */
+ public function testGet()
+ {
+ $engine = new HtmlEngine();
+
+ $file = $this->createTempFile('<div>%main_content%</div>');
+
+ $data = $engine->get($file, ['main_content' => 'Lorem ipsum dolor sit']);
+ $this->assertEquals('<div>Lorem ipsum dolor sit</div>', $data);
+ }
+
+ /**
+ * @covers \Engelsystem\Renderer\HtmlEngine::canRender
+ */
+ public function testCanRender()
+ {
+ $engine = new HtmlEngine();
+
+ $this->assertFalse($engine->canRender('/dev/null'));
+
+ $file = $this->createTempFile();
+ $this->assertTrue($engine->canRender($file));
+
+ $htmFile = $this->createTempFile('', '.htm');
+ $this->assertTrue($engine->canRender($htmFile));
+ }
+
+ /**
+ * @param string $content
+ * @param string $extension
+ * @return string
+ */
+ protected function createTempFile($content = '', $extension = '.html')
+ {
+ $tmpFileName = tempnam(sys_get_temp_dir(), 'EngelsystemUnitTest');
+
+ $fileName = $tmpFileName . $extension;
+ rename($tmpFileName, $fileName);
+
+ file_put_contents($fileName, $content);
+
+ $this->tmpFileNames[] = $fileName;
+
+ return $fileName;
+ }
+
+ public function tearDown()
+ {
+ foreach ($this->tmpFileNames as $fileName) {
+ unlink($fileName);
+ }
+ }
+}