From 4794287b2d7aa716251dd9d8ec2973ec75103169 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 14 Dec 2017 23:26:39 +0100 Subject: [PATCH] TASK: Add test for command renderer --- Classes/Domain/Renderer/Command.php | 2 +- Tests/Unit/Domain/Renderer/CommandTest.php | 66 ++++++++++++++++++++++ phpunit.xml.dist | 4 +- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 Tests/Unit/Domain/Renderer/CommandTest.php diff --git a/Classes/Domain/Renderer/Command.php b/Classes/Domain/Renderer/Command.php index 0dab6bd..b6ec2f9 100644 --- a/Classes/Domain/Renderer/Command.php +++ b/Classes/Domain/Renderer/Command.php @@ -6,7 +6,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; class Command implements RendererInterface { - protected function getHtmlFromMjml($mjml) + public function getHtmlFromMjml($mjml) { $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mjml']); diff --git a/Tests/Unit/Domain/Renderer/CommandTest.php b/Tests/Unit/Domain/Renderer/CommandTest.php new file mode 100644 index 0000000..aa7a7fb --- /dev/null +++ b/Tests/Unit/Domain/Renderer/CommandTest.php @@ -0,0 +1,66 @@ + + + + + + + Easy and Quick + + + + Responsive + + + + + Discover + + + + + +'; + + public function setUp() + { + parent::setUp(); + $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); + } + + /** + * @test + */ + public function htmlIsReturnedForMjml() + { + $expectedHtml = '
Easy and Quick
Responsive

Discover

'; + $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mjml'] = serialize([ + 'nodeBinaryPath' => 'node', + 'mjmlBinaryPath' => 'node_modules/.bin/', + 'mjmlBinary' => 'mjml', + 'mjmlParams' => '-s -m', + ]); + + $subject = $this->objectManager->get(Command::class); + $html = $subject->getHtmlFromMjml(static::EXAMPLE_MJML_TEMPLATE); + $this->assertSame( + $expectedHtml, + $html, + 'Command renderer did not return expected HTML.' + ); + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0455ed1..f8dad0b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,13 +16,13 @@ - ./Tests/Unit/ + ./Tests/Unit - Classes + ./Classes