From 5055c53e2bb9ba9c13df44ff7c5552010f0ae78f Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Thu, 16 May 2019 16:13:06 +0200 Subject: [PATCH] Add test for footer [MAILPOET-2086] --- lib/Newsletter/Renderer/Blocks/Footer.php | 3 +- .../Newsletter/Renderer/Blocks/FooterTest.php | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 tests/unit/Newsletter/Renderer/Blocks/FooterTest.php diff --git a/lib/Newsletter/Renderer/Blocks/Footer.php b/lib/Newsletter/Renderer/Blocks/Footer.php index 11a8aeefbc..1a9923fd6c 100644 --- a/lib/Newsletter/Renderer/Blocks/Footer.php +++ b/lib/Newsletter/Renderer/Blocks/Footer.php @@ -34,8 +34,7 @@ class Footer { $style = EHelper::escapeHtmlStyleAttr($style); $template = ' - + ' . str_replace('&', '&', $DOM->html()) . ' '; diff --git a/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php b/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php new file mode 100644 index 0000000000..bdf2e6702b --- /dev/null +++ b/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php @@ -0,0 +1,54 @@ + 'footer', + 'text' => '

Footer text. link

', + 'styles' => [ + 'block' => [ + 'backgroundColor' => 'transparent', + ], + 'text' => [ + 'fontColor' => '#222222', + 'fontFamily' => 'Roboto', + 'fontSize' => '12px', + 'textAlign' => 'center', + ], + 'link' => [ + 'fontColor' => '#689f2c', + 'textDecoration' => 'none', + ], + ], + ]; + + function testItRendersCorrectly() { + $output = Footer::render($this->block); + $expected_result = ' + + + Footer text. link + + '; + expect($output)->equals($expected_result); + } + + function testItRendersWithBackgroundColor() { + $this->block['styles']['block']['backgroundColor'] = '#f0f0f0'; + $output = Footer::render($this->block); + $expected_result = ' + + + Footer text. link + + '; + expect($output)->equals($expected_result); + } + + function testItPrefersInlinedCssForLinks() { + $this->block['text'] = '

Footer text. link

'; + $output = Footer::render($this->block); + expect($output)->contains('link'); + } +}