Files
piratepoet/tests/unit/Newsletter/Renderer/Blocks/FooterTest.php
Rodrigo Primo 030bd8c1c8 Fix PHPStan parameter type error introduced after update to version 0.12.83
This commit fixes the following PHPStan errors introduced after the update to version 0.12.83:

```
 ------ ----------------------------------------------------------------------
  Line   lib/Newsletter/Renderer/Blocks/Footer.php
 ------ ----------------------------------------------------------------------
  18     Parameter #1 $html of method MailPoet\Util\pQuery\pQuery::parseStr()
         expects string, array|string|null given.
 ------ ----------------------------------------------------------------------

 ------ ----------------------------------------------------------------------
  Line   lib/Newsletter/Renderer/Blocks/Header.php
 ------ ----------------------------------------------------------------------
  18     Parameter #1 $html of method MailPoet\Util\pQuery\pQuery::parseStr()
         expects string, array|string|null given.
 ------ ----------------------------------------------------------------------
```

[MAILPOET-3491]
2021-04-12 08:55:14 +02:00

62 lines
2.3 KiB
PHP

<?php
namespace MailPoet\Newsletter\Renderer\Blocks;
class FooterTest extends \MailPoetUnitTest {
private $block = [
'type' => 'footer',
'text' => '<p>Footer text. <a href="http://example.com">link</a></p>',
'styles' => [
'block' => [
'backgroundColor' => 'transparent',
],
'text' => [
'fontColor' => '#222222',
'fontFamily' => 'Roboto',
'fontSize' => '12px',
'textAlign' => 'center',
],
'link' => [
'fontColor' => '#689f2c',
'textDecoration' => 'none',
],
],
];
public function testItRendersCorrectly() {
$output = (new Footer)->render($this->block);
$expectedResult = '
<tr>
<td class="mailpoet_header_footer_padded mailpoet_footer" style="line-height: 19.2px;color: #222222;font-family: roboto, \'helvetica neue\', helvetica, arial, sans-serif;font-size: 12px;text-align: center;">
Footer text. <a href="http://example.com" style="color:#689f2c;text-decoration:none">link</a>
</td>
</tr>';
expect($output)->equals($expectedResult);
}
public function testItRendersWithBackgroundColor() {
$this->block['styles']['block']['backgroundColor'] = '#f0f0f0';
$output = (new Footer)->render($this->block);
$expectedResult = '
<tr>
<td class="mailpoet_header_footer_padded mailpoet_footer" bgcolor="#f0f0f0" style="line-height: 19.2px;background-color: #f0f0f0;color: #222222;font-family: roboto, \'helvetica neue\', helvetica, arial, sans-serif;font-size: 12px;text-align: center;">
Footer text. <a href="http://example.com" style="color:#689f2c;text-decoration:none">link</a>
</td>
</tr>';
expect($output)->equals($expectedResult);
}
public function testItPrefersInlinedCssForLinks() {
$this->block['text'] = '<p>Footer text. <a href="http://example.com" style="color:#aaaaaa;">link</a></p>';
$output = (new Footer)->render($this->block);
expect($output)->stringContainsString('<a href="http://example.com" style="color:#aaaaaa;text-decoration:none">link</a>');
}
public function testItRaisesExceptionIfTextIsNotString() {
$this->block['text'] = ['some', 'array'];
$this->expectException('RuntimeException');
(new Footer)->render($this->block);
}
}