diff --git a/.gitignore b/.gitignore
index a11232f..cb300fb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,7 @@
.sass-cache
node_modules
bower_components
+composer.lock
+package-lock.json
+typo3
+vendor
diff --git a/.travis.yml b/.travis.yml
index 4b49b98..932656a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,3 +12,4 @@ install:
script:
- composer lint
- composer cgl
+ - composer test
diff --git a/Classes/Domain/Finishers/MjmlEmailFinisher.php b/Classes/Domain/Finishers/MjmlEmailFinisher.php
index 6fd9876..a2321f9 100644
--- a/Classes/Domain/Finishers/MjmlEmailFinisher.php
+++ b/Classes/Domain/Finishers/MjmlEmailFinisher.php
@@ -1,20 +1,6 @@
getEscapedCommand($cmd, $args), $result, $returnValue);
+
+ GeneralUtility::unlink_tempfile($temporaryMjmlFileWithPath);
+
+ return implode('', $result);
+ }
+
+ /**
+ * @param string $cmd
+ * @param string $args
+ * @return string
+ */
+ protected function getEscapedCommand(string $cmd, string $args)
+ {
+ $escapedCmd = escapeshellcmd($cmd);
+
+ $argsArray = explode(' ', $args);
+ $escapedArgsArray = CommandUtility::escapeShellArguments($argsArray);
+ $escapedArgs = implode(' ', $escapedArgsArray);
+
+ return $escapedCmd . ' ' . $escapedArgs;
+ }
+}
diff --git a/Classes/Domain/Renderer/RendererInterface.php b/Classes/Domain/Renderer/RendererInterface.php
new file mode 100644
index 0000000..5cef1b2
--- /dev/null
+++ b/Classes/Domain/Renderer/RendererInterface.php
@@ -0,0 +1,16 @@
+renderer = $renderer;
+ if ($this->renderer === null) {
+ $this->renderer = $this->objectManager->get(RendererInterface::class);
+ }
+ }
+
public function render($actionName = null)
{
- return $this->getHtmlFromMjml(parent::render());
- }
-
- protected function getHtmlFromMjml($mjml)
- {
- $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mjml']);
-
- $temporaryMjmlFileWithPath = GeneralUtility::tempnam('mjml_', '.mjml');
-
- GeneralUtility::writeFileToTypo3tempDir($temporaryMjmlFileWithPath, $mjml);
-
- // see https://mjml.io/download and https://www.npmjs.com/package/mjml-cli
- $cmd = $configuration['nodeBinaryPath'] . ' ' . $configuration['mjmlBinaryPath'] . $configuration['mjmlBinary'];
- $args = $configuration['mjmlParams'] . ' ' . $temporaryMjmlFileWithPath;
-
- $result = [];
- $returnValue = '';
- CommandUtility::exec($this->getEscapedCommand($cmd, $args), $result, $returnValue);
-
- GeneralUtility::unlink_tempfile($temporaryMjmlFileWithPath);
-
- return implode('', $result);
- }
-
- /**
- * @param string $cmd
- * @param string $args
- * @return string
- */
- private function getEscapedCommand(string $cmd, string $args)
- {
- $escapedCmd = escapeshellcmd($cmd);
-
- $argsArray = explode(' ', $args);
- $escapedArgsArray = CommandUtility::escapeShellArguments($argsArray);
- $escapedArgs = implode(' ', $escapedArgsArray);
-
- return $escapedCmd . ' ' . $escapedArgs;
+ return $this->renderer->getHtmlFromMjml(parent::render($actionName));
}
}
diff --git a/Tests/Unit/AbstractUnitTestCase.php b/Tests/Unit/AbstractUnitTestCase.php
new file mode 100644
index 0000000..814e944
--- /dev/null
+++ b/Tests/Unit/AbstractUnitTestCase.php
@@ -0,0 +1,22 @@
+setCacheConfigurations([
+ 'extbase_object' => [
+ 'backend' => NullBackend::class,
+ ],
+ ]);
+ }
+}
diff --git a/Tests/Unit/View/MjmlBasedViewTest.php b/Tests/Unit/View/MjmlBasedViewTest.php
new file mode 100644
index 0000000..5648444
--- /dev/null
+++ b/Tests/Unit/View/MjmlBasedViewTest.php
@@ -0,0 +1,55 @@
+
+