Files
piratepoet/tests/unit/Newsletter/Renderer/Blocks/HeaderTest.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 HeaderTest extends \MailPoetUnitTest {
private $block = [
'type' => 'header',
'text' => '<a href="[link:newsletter_view_in_browser_url]">View this in your browser.</a>',
'styles' => [
'block' => [
'backgroundColor' => 'transparent',
],
'text' => [
'fontColor' => '#222222',
'fontFamily' => 'Arial',
'fontSize' => '12px',
'textAlign' => 'left',
],
'link' => [
'fontColor' => '#6cb7d4',
'textDecoration' => 'underline',
],
],
];
public function testItRendersCorrectly() {
$output = (new Header)->render($this->block);
$expectedResult = '
<tr>
<td class="mailpoet_header_footer_padded mailpoet_header" style="line-height: 19.2px;color: #222222;font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif;font-size: 12px;text-align: left;">
<a href="[link:newsletter_view_in_browser_url]" style="color:#6cb7d4;text-decoration:underline">View this in your browser.</a>
</td>
</tr>';
expect($output)->equals($expectedResult);
}
public function testItRendersBackgroundColorCorrectly() {
$this->block['styles']['block']['backgroundColor'] = '#f0f0f0';
$output = (new Header)->render($this->block);
$expectedResult = '
<tr>
<td class="mailpoet_header_footer_padded mailpoet_header" bgcolor="#f0f0f0" style="line-height: 19.2px;background-color: #f0f0f0;color: #222222;font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif;font-size: 12px;text-align: left;">
<a href="[link:newsletter_view_in_browser_url]" style="color:#6cb7d4;text-decoration:underline">View this in your browser.</a>
</td>
</tr>';
expect($output)->equals($expectedResult);
}
public function testItPrefersInlinedCssForLinks() {
$this->block['text'] = '<p>Header 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:underline">link</a>');
}
public function testItRaisesExceptionIfTextIsNotString() {
$this->block['text'] = ['some', 'array'];
$this->expectException('RuntimeException');
(new Header)->render($this->block);
}
}