');
- }
+ public function testItEscapesAttributes(): void {
+ $parsedBlock = array(
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ ),
+ ),
+ 'email_attrs' => array(),
+ );
+ $parsedBlock['attrs']['layout']['justifyContent'] = '">
' );
+ }
- public function testInComputesProperWidthsForReasonableSettings(): void {
- $parsedBlock = [
- 'innerBlocks' => [],
- 'email_attrs' => [
- 'width' => '640px',
- ],
- ];
+ public function testInComputesProperWidthsForReasonableSettings(): void {
+ $parsedBlock = array(
+ 'innerBlocks' => array(),
+ 'email_attrs' => array(
+ 'width' => '640px',
+ ),
+ );
- // 50% and 25%
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '50'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => ['width' => '25'],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:312px;');
- verify($flexItems[1])->stringContainsString('width:148px;');
+ // 50% and 25%
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '50' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array( 'width' => '25' ),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:312px;' );
+ verify( $flexItems[1] )->stringContainsString( 'width:148px;' );
- // 25% and 25% and auto
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '25'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => ['width' => '25'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 3',
- 'attrs' => [],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:148px;');
- verify($flexItems[1])->stringContainsString('width:148px;');
- verify($flexItems[2])->stringNotContainsString('width:');
+ // 25% and 25% and auto
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '25' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array( 'width' => '25' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 3',
+ 'attrs' => array(),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:148px;' );
+ verify( $flexItems[1] )->stringContainsString( 'width:148px;' );
+ verify( $flexItems[2] )->stringNotContainsString( 'width:' );
- // 50% and 50%
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '50'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => ['width' => '50'],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:312px;');
- verify($flexItems[1])->stringContainsString('width:312px;');
- }
+ // 50% and 50%
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '50' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array( 'width' => '50' ),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:312px;' );
+ verify( $flexItems[1] )->stringContainsString( 'width:312px;' );
+ }
- public function testInComputesWidthsForStrangeSettingsValues(): void {
- $parsedBlock = [
- 'innerBlocks' => [],
- 'email_attrs' => [
- 'width' => '640px',
- ],
- ];
+ public function testInComputesWidthsForStrangeSettingsValues(): void {
+ $parsedBlock = array(
+ 'innerBlocks' => array(),
+ 'email_attrs' => array(
+ 'width' => '640px',
+ ),
+ );
- // 100% and 25%
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '100'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => ['width' => '25'],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:508px;');
- verify($flexItems[1])->stringContainsString('width:105px;');
+ // 100% and 25%
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '100' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array( 'width' => '25' ),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:508px;' );
+ verify( $flexItems[1] )->stringContainsString( 'width:105px;' );
- // 100% and 100%
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '100'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => ['width' => '100'],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:312px;');
- verify($flexItems[1])->stringContainsString('width:312px;');
+ // 100% and 100%
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '100' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array( 'width' => '100' ),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:312px;' );
+ verify( $flexItems[1] )->stringContainsString( 'width:312px;' );
+ // 100% and auto
+ $parsedBlock['innerBlocks'] = array(
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 1',
+ 'attrs' => array( 'width' => '100' ),
+ ),
+ array(
+ 'blockName' => 'dummy/block',
+ 'innerHtml' => 'Dummy 2',
+ 'attrs' => array(),
+ ),
+ );
+ $output = $this->renderer->render_inner_blocks_in_layout( $parsedBlock, $this->settingsController );
+ $flexItems = $this->getFlexItemsFromOutput( $output );
+ verify( $flexItems[0] )->stringContainsString( 'width:508px;' );
+ verify( $flexItems[1] )->stringNotContainsString( 'width:' );
+ }
- // 100% and auto
- $parsedBlock['innerBlocks'] = [
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 1',
- 'attrs' => ['width' => '100'],
- ],
- [
- 'blockName' => 'dummy/block',
- 'innerHtml' => 'Dummy 2',
- 'attrs' => [],
- ],
- ];
- $output = $this->renderer->render_inner_blocks_in_layout($parsedBlock, $this->settingsController);
- $flexItems = $this->getFlexItemsFromOutput($output);
- verify($flexItems[0])->stringContainsString('width:508px;');
- verify($flexItems[1])->stringNotContainsString('width:');
- }
+ private function getFlexItemsFromOutput( string $output ): array {
+ $matches = array();
+ preg_match_all( '/
/', $output, $matches );
+ return explode( '><', $matches[0][0] ?? array() );
+ }
- private function getFlexItemsFromOutput(string $output): array {
- $matches = [];
- preg_match_all('/ | /', $output, $matches);
- return explode('><', $matches[0][0] ?? []);
- }
+ public function renderDummyBlock( $blockContent, $parsedBlock ): string {
+ $dummyRenderer = new Dummy_Block_Renderer();
+ return $dummyRenderer->render( $blockContent, $parsedBlock, $this->settingsController );
+ }
- public function renderDummyBlock($blockContent, $parsedBlock): string {
- $dummyRenderer = new Dummy_Block_Renderer();
- return $dummyRenderer->render($blockContent, $parsedBlock, $this->settingsController);
- }
-
- public function _after(): void {
- parent::_after();
- unregister_block_type('dummy/block');
- remove_filter('render_block', [$this, 'renderDummyBlock'], 10);
- }
+ public function _after(): void {
+ parent::_after();
+ unregister_block_type( 'dummy/block' );
+ remove_filter( 'render_block', array( $this, 'renderDummyBlock' ), 10 );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php b/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
index e94980b5fa..196b6d532c 100644
--- a/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
+++ b/packages/php/email-editor/tests/integration/Engine/Renderer/Renderer_Test.php
@@ -7,116 +7,123 @@ use MailPoet\EmailEditor\Engine\Settings_Controller;
use MailPoet\EmailEditor\Engine\Theme_Controller;
class Renderer_Test extends \MailPoetTest {
- private Renderer $renderer;
+ private Renderer $renderer;
- private \WP_Post $emailPost;
+ private \WP_Post $emailPost;
- public function _before(): void {
- parent::_before();
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->renderer = $this->diContainer->get(Renderer::class);
- $styles = [
- 'spacing' => [
- 'padding' => [
- 'bottom' => '4px',
- 'top' => '3px',
- 'left' => '2px',
- 'right' => '1px',
- ],
- ],
- 'typography' => [
- 'fontFamily' => 'Test Font Family',
- ],
- 'color' => [
- 'background' => '#123456',
- ],
- ];
- $themeJsonMock = $this->createMock(\WP_Theme_JSON::class);
- $themeJsonMock->method('get_data')->willReturn([
- 'styles' => $styles,
- ]);
- $settingsControllerMock = $this->createMock(Settings_Controller::class);
- $settingsControllerMock->method('get_email_styles')->willReturn($styles);
- $themeControllerMock = $this->createMock(Theme_Controller::class);
- $themeControllerMock->method('get_theme')->willReturn($themeJsonMock);
- $themeControllerMock->method('get_styles')->willReturn($styles);
- $themeControllerMock->method('get_layout_settings')->willReturn(['contentSize' => '660px']);
+ public function _before(): void {
+ parent::_before();
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->renderer = $this->diContainer->get( Renderer::class );
+ $styles = array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'bottom' => '4px',
+ 'top' => '3px',
+ 'left' => '2px',
+ 'right' => '1px',
+ ),
+ ),
+ 'typography' => array(
+ 'fontFamily' => 'Test Font Family',
+ ),
+ 'color' => array(
+ 'background' => '#123456',
+ ),
+ );
+ $themeJsonMock = $this->createMock( \WP_Theme_JSON::class );
+ $themeJsonMock->method( 'get_data' )->willReturn(
+ array(
+ 'styles' => $styles,
+ )
+ );
+ $settingsControllerMock = $this->createMock( Settings_Controller::class );
+ $settingsControllerMock->method( 'get_email_styles' )->willReturn( $styles );
+ $themeControllerMock = $this->createMock( Theme_Controller::class );
+ $themeControllerMock->method( 'get_theme' )->willReturn( $themeJsonMock );
+ $themeControllerMock->method( 'get_styles' )->willReturn( $styles );
+ $themeControllerMock->method( 'get_layout_settings' )->willReturn( array( 'contentSize' => '660px' ) );
- $this->renderer = $this->getServiceWithOverrides(Renderer::class, [
- 'settingsController' => $settingsControllerMock,
- 'themeController' => $themeControllerMock,
- ]);
- $this->emailPost = $this->tester->createPost([
- 'post_content' => ' Hello! ',
- ]);
- }
+ $this->renderer = $this->getServiceWithOverrides(
+ Renderer::class,
+ array(
+ 'settingsController' => $settingsControllerMock,
+ 'themeController' => $themeControllerMock,
+ )
+ );
+ $this->emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => 'Hello! ',
+ )
+ );
+ }
- public function testItRendersTemplateWithContent(): void {
- $rendered = $this->renderer->render(
- $this->emailPost,
- 'Subject',
- 'Preheader content',
- 'en',
- 'noindex,nofollow'
- );
- verify($rendered['html'])->stringContainsString('Subject');
- verify($rendered['html'])->stringContainsString('Preheader content');
- verify($rendered['html'])->stringContainsString('noindex,nofollow');
- verify($rendered['html'])->stringContainsString('Hello!');
+ public function testItRendersTemplateWithContent(): void {
+ $rendered = $this->renderer->render(
+ $this->emailPost,
+ 'Subject',
+ 'Preheader content',
+ 'en',
+ 'noindex,nofollow'
+ );
+ verify( $rendered['html'] )->stringContainsString( 'Subject' );
+ verify( $rendered['html'] )->stringContainsString( 'Preheader content' );
+ verify( $rendered['html'] )->stringContainsString( 'noindex,nofollow' );
+ verify( $rendered['html'] )->stringContainsString( 'Hello!' );
- verify($rendered['text'])->stringContainsString('Preheader content');
- verify($rendered['text'])->stringContainsString('Hello!');
- }
+ verify( $rendered['text'] )->stringContainsString( 'Preheader content' );
+ verify( $rendered['text'] )->stringContainsString( 'Hello!' );
+ }
- public function testItInlinesStyles(): void {
- $stylesCallback = function ($styles) {
- return $styles . 'body { color: pink; }';
- };
- add_filter('mailpoet_email_renderer_styles', $stylesCallback);
- $rendered = $this->renderer->render($this->emailPost, 'Subject', '', 'en');
- $style = $this->getStylesValueForTag($rendered['html'], ['tag_name' => 'body']);
- verify($style)->stringContainsString('color: pink');
- remove_filter('mailpoet_email_renderer_styles', $stylesCallback);
- }
+ public function testItInlinesStyles(): void {
+ $stylesCallback = function ( $styles ) {
+ return $styles . 'body { color: pink; }';
+ };
+ add_filter( 'mailpoet_email_renderer_styles', $stylesCallback );
+ $rendered = $this->renderer->render( $this->emailPost, 'Subject', '', 'en' );
+ $style = $this->getStylesValueForTag( $rendered['html'], array( 'tag_name' => 'body' ) );
+ verify( $style )->stringContainsString( 'color: pink' );
+ remove_filter( 'mailpoet_email_renderer_styles', $stylesCallback );
+ }
- public function testItInlinesBodyStyles(): void {
- $rendered = $this->renderer->render($this->emailPost, 'Subject', '', 'en');
- $style = $this->getStylesValueForTag($rendered['html'], ['tag_name' => 'body']);
- verify($style)->stringContainsString('margin: 0; padding: 0;');
- }
+ public function testItInlinesBodyStyles(): void {
+ $rendered = $this->renderer->render( $this->emailPost, 'Subject', '', 'en' );
+ $style = $this->getStylesValueForTag( $rendered['html'], array( 'tag_name' => 'body' ) );
+ verify( $style )->stringContainsString( 'margin: 0; padding: 0;' );
+ }
- public function testItInlinesWrappersStyles(): void {
- $rendered = $this->renderer->render($this->emailPost, 'Subject', '', 'en');
+ public function testItInlinesWrappersStyles(): void {
+ $rendered = $this->renderer->render( $this->emailPost, 'Subject', '', 'en' );
- // Verify body element styles
- $style = $this->getStylesValueForTag($rendered['html'], ['tag_name' => 'body']);
- verify($style)->stringContainsString('background-color: #123456');
+ // Verify body element styles
+ $style = $this->getStylesValueForTag( $rendered['html'], array( 'tag_name' => 'body' ) );
+ verify( $style )->stringContainsString( 'background-color: #123456' );
- // Verify layout element styles
- $doc = new \DOMDocument();
- $doc->loadHTML($rendered['html']);
- $xpath = new \DOMXPath($doc);
- $wrapper = null;
- $nodes = $xpath->query('//div[contains(@class, "email_layout_wrapper")]');
- if (($nodes instanceof \DOMNodeList) && $nodes->length > 0) {
- $wrapper = $nodes->item(0);
- }
- $this->assertInstanceOf(\DOMElement::class, $wrapper);
- $style = $wrapper->getAttribute('style');
- verify($style)->stringContainsString('background-color: #123456');
- verify($style)->stringContainsString('font-family: Test Font Family;');
- verify($style)->stringContainsString('padding-top: 3px;');
- verify($style)->stringContainsString('padding-bottom: 4px;');
- verify($style)->stringContainsString('padding-left: 2px;');
- verify($style)->stringContainsString('padding-right: 1px;');
- verify($style)->stringContainsString('max-width: 660px;');
- }
+ // Verify layout element styles
+ $doc = new \DOMDocument();
+ $doc->loadHTML( $rendered['html'] );
+ $xpath = new \DOMXPath( $doc );
+ $wrapper = null;
+ $nodes = $xpath->query( '//div[contains(@class, "email_layout_wrapper")]' );
+ if ( ( $nodes instanceof \DOMNodeList ) && $nodes->length > 0 ) {
+ $wrapper = $nodes->item( 0 );
+ }
+ $this->assertInstanceOf( \DOMElement::class, $wrapper );
+ $style = $wrapper->getAttribute( 'style' );
+ verify( $style )->stringContainsString( 'background-color: #123456' );
+ verify( $style )->stringContainsString( 'font-family: Test Font Family;' );
+ verify( $style )->stringContainsString( 'padding-top: 3px;' );
+ verify( $style )->stringContainsString( 'padding-bottom: 4px;' );
+ verify( $style )->stringContainsString( 'padding-left: 2px;' );
+ verify( $style )->stringContainsString( 'padding-right: 1px;' );
+ verify( $style )->stringContainsString( 'max-width: 660px;' );
+ }
- private function getStylesValueForTag(string $html, array $query): ?string {
- $html = new \WP_HTML_Tag_Processor($html);
- if ($html->next_tag($query)) {
- return $html->get_attribute('style');
- }
- return null;
- }
+ private function getStylesValueForTag( string $html, array $query ): ?string {
+ $html = new \WP_HTML_Tag_Processor( $html );
+ if ( $html->next_tag( $query ) ) {
+ return $html->get_attribute( 'style' );
+ }
+ return null;
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Engine/Theme_Controller_Test.php b/packages/php/email-editor/tests/integration/Engine/Theme_Controller_Test.php
index 275ba8f74a..6362f340a2 100644
--- a/packages/php/email-editor/tests/integration/Engine/Theme_Controller_Test.php
+++ b/packages/php/email-editor/tests/integration/Engine/Theme_Controller_Test.php
@@ -3,109 +3,109 @@
namespace MailPoet\EmailEditor\Engine;
class Theme_Controller_Test extends \MailPoetTest {
- private Theme_Controller $themeController;
+ private Theme_Controller $themeController;
- public function _before() {
- parent::_before();
- $this->themeController = $this->diContainer->get(Theme_Controller::class);
- }
+ public function _before() {
+ parent::_before();
+ $this->themeController = $this->diContainer->get( Theme_Controller::class );
+ }
- public function testItGeneratesCssStylesForRenderer() {
- $css = $this->themeController->get_stylesheet_for_rendering();
- // Font families
- verify($css)->stringContainsString('.has-arial-font-family');
- verify($css)->stringContainsString('.has-comic-sans-ms-font-family');
- verify($css)->stringContainsString('.has-courier-new-font-family');
- verify($css)->stringContainsString('.has-georgia-font-family');
- verify($css)->stringContainsString('.has-lucida-font-family');
- verify($css)->stringContainsString('.has-tahoma-font-family');
- verify($css)->stringContainsString('.has-times-new-roman-font-family');
- verify($css)->stringContainsString('.has-trebuchet-ms-font-family');
- verify($css)->stringContainsString('.has-verdana-font-family');
- verify($css)->stringContainsString('.has-arvo-font-family');
- verify($css)->stringContainsString('.has-lato-font-family');
- verify($css)->stringContainsString('.has-merriweather-font-family');
- verify($css)->stringContainsString('.has-merriweather-sans-font-family');
- verify($css)->stringContainsString('.has-noticia-text-font-family');
- verify($css)->stringContainsString('.has-open-sans-font-family');
- verify($css)->stringContainsString('.has-playfair-display-font-family');
- verify($css)->stringContainsString('.has-roboto-font-family');
- verify($css)->stringContainsString('.has-source-sans-pro-font-family');
- verify($css)->stringContainsString('.has-oswald-font-family');
- verify($css)->stringContainsString('.has-raleway-font-family');
- verify($css)->stringContainsString('.has-permanent-marker-font-family');
- verify($css)->stringContainsString('.has-pacifico-font-family');
+ public function testItGeneratesCssStylesForRenderer() {
+ $css = $this->themeController->get_stylesheet_for_rendering();
+ // Font families
+ verify( $css )->stringContainsString( '.has-arial-font-family' );
+ verify( $css )->stringContainsString( '.has-comic-sans-ms-font-family' );
+ verify( $css )->stringContainsString( '.has-courier-new-font-family' );
+ verify( $css )->stringContainsString( '.has-georgia-font-family' );
+ verify( $css )->stringContainsString( '.has-lucida-font-family' );
+ verify( $css )->stringContainsString( '.has-tahoma-font-family' );
+ verify( $css )->stringContainsString( '.has-times-new-roman-font-family' );
+ verify( $css )->stringContainsString( '.has-trebuchet-ms-font-family' );
+ verify( $css )->stringContainsString( '.has-verdana-font-family' );
+ verify( $css )->stringContainsString( '.has-arvo-font-family' );
+ verify( $css )->stringContainsString( '.has-lato-font-family' );
+ verify( $css )->stringContainsString( '.has-merriweather-font-family' );
+ verify( $css )->stringContainsString( '.has-merriweather-sans-font-family' );
+ verify( $css )->stringContainsString( '.has-noticia-text-font-family' );
+ verify( $css )->stringContainsString( '.has-open-sans-font-family' );
+ verify( $css )->stringContainsString( '.has-playfair-display-font-family' );
+ verify( $css )->stringContainsString( '.has-roboto-font-family' );
+ verify( $css )->stringContainsString( '.has-source-sans-pro-font-family' );
+ verify( $css )->stringContainsString( '.has-oswald-font-family' );
+ verify( $css )->stringContainsString( '.has-raleway-font-family' );
+ verify( $css )->stringContainsString( '.has-permanent-marker-font-family' );
+ verify( $css )->stringContainsString( '.has-pacifico-font-family' );
- verify($css)->stringContainsString('.has-small-font-size');
- verify($css)->stringContainsString('.has-medium-font-size');
- verify($css)->stringContainsString('.has-large-font-size');
- verify($css)->stringContainsString('.has-x-large-font-size');
+ verify( $css )->stringContainsString( '.has-small-font-size' );
+ verify( $css )->stringContainsString( '.has-medium-font-size' );
+ verify( $css )->stringContainsString( '.has-large-font-size' );
+ verify( $css )->stringContainsString( '.has-x-large-font-size' );
- // Font sizes
- verify($css)->stringContainsString('.has-small-font-size');
- verify($css)->stringContainsString('.has-medium-font-size');
- verify($css)->stringContainsString('.has-large-font-size');
- verify($css)->stringContainsString('.has-x-large-font-size');
+ // Font sizes
+ verify( $css )->stringContainsString( '.has-small-font-size' );
+ verify( $css )->stringContainsString( '.has-medium-font-size' );
+ verify( $css )->stringContainsString( '.has-large-font-size' );
+ verify( $css )->stringContainsString( '.has-x-large-font-size' );
- // Colors
- verify($css)->stringContainsString('.has-black-color');
- verify($css)->stringContainsString('.has-black-background-color');
- verify($css)->stringContainsString('.has-black-border-color');
+ // Colors
+ verify( $css )->stringContainsString( '.has-black-color' );
+ verify( $css )->stringContainsString( '.has-black-background-color' );
+ verify( $css )->stringContainsString( '.has-black-border-color' );
- verify($css)->stringContainsString('.has-black-color');
- verify($css)->stringContainsString('.has-black-background-color');
- verify($css)->stringContainsString('.has-black-border-color');
+ verify( $css )->stringContainsString( '.has-black-color' );
+ verify( $css )->stringContainsString( '.has-black-background-color' );
+ verify( $css )->stringContainsString( '.has-black-border-color' );
- $this->checkCorrectThemeConfiguration();
- if (wp_get_theme()->get('Name') === 'Twenty Twenty-One') {
- verify($css)->stringContainsString('.has-yellow-background-color');
- verify($css)->stringContainsString('.has-yellow-color');
- verify($css)->stringContainsString('.has-yellow-border-color');
- }
- }
+ $this->checkCorrectThemeConfiguration();
+ if ( wp_get_theme()->get( 'Name' ) === 'Twenty Twenty-One' ) {
+ verify( $css )->stringContainsString( '.has-yellow-background-color' );
+ verify( $css )->stringContainsString( '.has-yellow-color' );
+ verify( $css )->stringContainsString( '.has-yellow-border-color' );
+ }
+ }
- public function testItCanTranslateFontSizeSlug() {
- verify($this->themeController->translate_slug_to_font_size('small'))->equals('13px');
- verify($this->themeController->translate_slug_to_font_size('medium'))->equals('16px');
- verify($this->themeController->translate_slug_to_font_size('large'))->equals('28px');
- verify($this->themeController->translate_slug_to_font_size('x-large'))->equals('42px');
- verify($this->themeController->translate_slug_to_font_size('unknown'))->equals('unknown');
- }
+ public function testItCanTranslateFontSizeSlug() {
+ verify( $this->themeController->translate_slug_to_font_size( 'small' ) )->equals( '13px' );
+ verify( $this->themeController->translate_slug_to_font_size( 'medium' ) )->equals( '16px' );
+ verify( $this->themeController->translate_slug_to_font_size( 'large' ) )->equals( '28px' );
+ verify( $this->themeController->translate_slug_to_font_size( 'x-large' ) )->equals( '42px' );
+ verify( $this->themeController->translate_slug_to_font_size( 'unknown' ) )->equals( 'unknown' );
+ }
- public function testItCanTranslateColorSlug() {
- verify($this->themeController->translate_slug_to_color('black'))->equals('#000000');
- verify($this->themeController->translate_slug_to_color('white'))->equals('#ffffff');
- verify($this->themeController->translate_slug_to_color('cyan-bluish-gray'))->equals('#abb8c3');
- verify($this->themeController->translate_slug_to_color('pale-pink'))->equals('#f78da7');
- $this->checkCorrectThemeConfiguration();
- if (wp_get_theme()->get('Name') === 'Twenty Twenty-One') {
- verify($this->themeController->translate_slug_to_color('yellow'))->equals('#eeeadd');
- }
- }
+ public function testItCanTranslateColorSlug() {
+ verify( $this->themeController->translate_slug_to_color( 'black' ) )->equals( '#000000' );
+ verify( $this->themeController->translate_slug_to_color( 'white' ) )->equals( '#ffffff' );
+ verify( $this->themeController->translate_slug_to_color( 'cyan-bluish-gray' ) )->equals( '#abb8c3' );
+ verify( $this->themeController->translate_slug_to_color( 'pale-pink' ) )->equals( '#f78da7' );
+ $this->checkCorrectThemeConfiguration();
+ if ( wp_get_theme()->get( 'Name' ) === 'Twenty Twenty-One' ) {
+ verify( $this->themeController->translate_slug_to_color( 'yellow' ) )->equals( '#eeeadd' );
+ }
+ }
- public function testItLoadsColorPaletteFromSiteTheme() {
- $this->checkCorrectThemeConfiguration();
- $settings = $this->themeController->get_settings();
- if (wp_get_theme()->get('Name') === 'Twenty Twenty-One') {
- verify($settings['color']['palette']['theme'])->notEmpty();
- }
- }
+ public function testItLoadsColorPaletteFromSiteTheme() {
+ $this->checkCorrectThemeConfiguration();
+ $settings = $this->themeController->get_settings();
+ if ( wp_get_theme()->get( 'Name' ) === 'Twenty Twenty-One' ) {
+ verify( $settings['color']['palette']['theme'] )->notEmpty();
+ }
+ }
- public function testItReturnsCorrectPresetVariablesMap() {
- $variableMap = $this->themeController->get_variables_values_map();
- verify($variableMap['--wp--preset--color--black'])->equals('#000000');
- verify($variableMap['--wp--preset--spacing--20'])->equals('20px');
- }
+ public function testItReturnsCorrectPresetVariablesMap() {
+ $variableMap = $this->themeController->get_variables_values_map();
+ verify( $variableMap['--wp--preset--color--black'] )->equals( '#000000' );
+ verify( $variableMap['--wp--preset--spacing--20'] )->equals( '20px' );
+ }
- /**
- * This test depends on using Twenty Twenty-One or Twenty Nineteen theme.
- * This method checks if the theme is correctly configured and trigger a failure if not
- * to prevent silent failures in case we change theme configuration in the test environment.
- */
- private function checkCorrectThemeConfiguration() {
- $expectedThemes = ['Twenty Twenty-One'];
- if (!in_array(wp_get_theme()->get('Name'), $expectedThemes)) {
- $this->fail('Test depends on using Twenty Twenty-One or Twenty Nineteen theme. If you changed the theme, please update the test.');
- }
- }
+ /**
+ * This test depends on using Twenty Twenty-One or Twenty Nineteen theme.
+ * This method checks if the theme is correctly configured and trigger a failure if not
+ * to prevent silent failures in case we change theme configuration in the test environment.
+ */
+ private function checkCorrectThemeConfiguration() {
+ $expectedThemes = array( 'Twenty Twenty-One' );
+ if ( ! in_array( wp_get_theme()->get( 'Name' ), $expectedThemes ) ) {
+ $this->fail( 'Test depends on using Twenty Twenty-One or Twenty Nineteen theme. If you changed the theme, please update the test.' );
+ }
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Button_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Button_Test.php
index b3324df214..22f61f7e31 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Button_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Button_Test.php
@@ -6,156 +6,168 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Button_Test extends \MailPoetTest {
- /** @var Button */
- private $buttonRenderer;
+ /** @var Button */
+ private $buttonRenderer;
- /** @var array */
- private $parsedButton = [
- 'blockName' => 'core/button',
- 'attrs' => [
- 'width' => 50,
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '10px',
- 'right' => '10px',
- 'top' => '10px',
- 'bottom' => '10px',
- ],
- ],
- 'color' => [
- 'background' => '#dddddd',
- 'text' => '#111111',
- ],
- ],
- ],
- 'innerBlocks' => [],
- 'innerHTML' => '',
- 'innerContent' => [''],
- 'email_attrs' => [
- 'color' => '#111111',
- 'width' => '320px',
- ],
- ];
+ /** @var array */
+ private $parsedButton = array(
+ 'blockName' => 'core/button',
+ 'attrs' => array(
+ 'width' => 50,
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ 'top' => '10px',
+ 'bottom' => '10px',
+ ),
+ ),
+ 'color' => array(
+ 'background' => '#dddddd',
+ 'text' => '#111111',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array( '' ),
+ 'email_attrs' => array(
+ 'color' => '#111111',
+ 'width' => '320px',
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before(): void {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->buttonRenderer = new Button();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before(): void {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->buttonRenderer = new Button();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersLink(): void {
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('href="http://example.com"');
- verify($output)->stringContainsString('Button Text');
- }
+ public function testItRendersLink(): void {
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'href="http://example.com"' );
+ verify( $output )->stringContainsString( 'Button Text' );
+ }
- public function testItRendersPaddingBasedOnAttributesValue(): void {
- $this->parsedButton['attrs']['style']['spacing']['padding'] = [
- 'left' => '10px',
- 'right' => '20px',
- 'top' => '30px',
- 'bottom' => '40px',
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('padding-left:10px;');
- verify($output)->stringContainsString('padding-right:20px;');
- verify($output)->stringContainsString('padding-top:30px;');
- verify($output)->stringContainsString('padding-bottom:40px;');
- }
+ public function testItRendersPaddingBasedOnAttributesValue(): void {
+ $this->parsedButton['attrs']['style']['spacing']['padding'] = array(
+ 'left' => '10px',
+ 'right' => '20px',
+ 'top' => '30px',
+ 'bottom' => '40px',
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'padding-left:10px;' );
+ verify( $output )->stringContainsString( 'padding-right:20px;' );
+ verify( $output )->stringContainsString( 'padding-top:30px;' );
+ verify( $output )->stringContainsString( 'padding-bottom:40px;' );
+ }
- public function testItRendersColors(): void {
- $this->parsedButton['attrs']['style']['color'] = [
- 'background' => '#000000',
- 'text' => '#111111',
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('background-color:#000000;');
- verify($output)->stringContainsString('color:#111111;');
- }
+ public function testItRendersColors(): void {
+ $this->parsedButton['attrs']['style']['color'] = array(
+ 'background' => '#000000',
+ 'text' => '#111111',
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'background-color:#000000;' );
+ verify( $output )->stringContainsString( 'color:#111111;' );
+ }
- public function testItRendersBorder(): void {
- $this->parsedButton['attrs']['style']['border'] = [
- 'width' => '10px',
- 'color' => '#111111',
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('border-color:#111111;');
- verify($output)->stringContainsString('border-width:10px;');
- verify($output)->stringContainsString('border-style:solid;');
- }
+ public function testItRendersBorder(): void {
+ $this->parsedButton['attrs']['style']['border'] = array(
+ 'width' => '10px',
+ 'color' => '#111111',
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'border-color:#111111;' );
+ verify( $output )->stringContainsString( 'border-width:10px;' );
+ verify( $output )->stringContainsString( 'border-style:solid;' );
+ }
- public function testItRendersEachSideSpecificBorder(): void {
- $this->parsedButton['attrs']['style']['border'] = [
- 'top' => ['width' => '1px', 'color' => '#111111'],
- 'right' => ['width' => '2px', 'color' => '#222222'],
- 'bottom' => ['width' => '3px', 'color' => '#333333'],
- 'left' => ['width' => '4px', 'color' => '#444444'],
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('border-top-width:1px;');
- verify($output)->stringContainsString('border-top-color:#111111;');
+ public function testItRendersEachSideSpecificBorder(): void {
+ $this->parsedButton['attrs']['style']['border'] = array(
+ 'top' => array(
+ 'width' => '1px',
+ 'color' => '#111111',
+ ),
+ 'right' => array(
+ 'width' => '2px',
+ 'color' => '#222222',
+ ),
+ 'bottom' => array(
+ 'width' => '3px',
+ 'color' => '#333333',
+ ),
+ 'left' => array(
+ 'width' => '4px',
+ 'color' => '#444444',
+ ),
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'border-top-width:1px;' );
+ verify( $output )->stringContainsString( 'border-top-color:#111111;' );
- verify($output)->stringContainsString('border-right-width:2px;');
- verify($output)->stringContainsString('border-right-color:#222222;');
+ verify( $output )->stringContainsString( 'border-right-width:2px;' );
+ verify( $output )->stringContainsString( 'border-right-color:#222222;' );
- verify($output)->stringContainsString('border-bottom-width:3px;');
- verify($output)->stringContainsString('border-bottom-color:#333333;');
+ verify( $output )->stringContainsString( 'border-bottom-width:3px;' );
+ verify( $output )->stringContainsString( 'border-bottom-color:#333333;' );
- verify($output)->stringContainsString('border-left-width:4px;');
- verify($output)->stringContainsString('border-left-color:#444444;');
+ verify( $output )->stringContainsString( 'border-left-width:4px;' );
+ verify( $output )->stringContainsString( 'border-left-color:#444444;' );
- verify($output)->stringContainsString('border-style:solid;');
- }
+ verify( $output )->stringContainsString( 'border-style:solid;' );
+ }
- public function testItRendersBorderRadius(): void {
- $this->parsedButton['attrs']['style']['border'] = [
- 'radius' => '10px',
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('border-radius:10px;');
- }
+ public function testItRendersBorderRadius(): void {
+ $this->parsedButton['attrs']['style']['border'] = array(
+ 'radius' => '10px',
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'border-radius:10px;' );
+ }
- public function testItRendersFontSize(): void {
- $this->parsedButton['attrs']['style']['typography']['fontSize'] = '10px';
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('font-size:10px;');
- }
+ public function testItRendersFontSize(): void {
+ $this->parsedButton['attrs']['style']['typography']['fontSize'] = '10px';
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'font-size:10px;' );
+ }
- public function testItRendersCornerSpecificBorderRadius(): void {
- $this->parsedButton['attrs']['style']['border']['radius'] = [
- 'topLeft' => '1px',
- 'topRight' => '2px',
- 'bottomLeft' => '3px',
- 'bottomRight' => '4px',
- ];
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- verify($output)->stringContainsString('border-top-left-radius:1px;');
- verify($output)->stringContainsString('border-top-right-radius:2px;');
- verify($output)->stringContainsString('border-bottom-left-radius:3px;');
- verify($output)->stringContainsString('border-bottom-right-radius:4px;');
- }
+ public function testItRendersCornerSpecificBorderRadius(): void {
+ $this->parsedButton['attrs']['style']['border']['radius'] = array(
+ 'topLeft' => '1px',
+ 'topRight' => '2px',
+ 'bottomLeft' => '3px',
+ 'bottomRight' => '4px',
+ );
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ verify( $output )->stringContainsString( 'border-top-left-radius:1px;' );
+ verify( $output )->stringContainsString( 'border-top-right-radius:2px;' );
+ verify( $output )->stringContainsString( 'border-bottom-left-radius:3px;' );
+ verify( $output )->stringContainsString( 'border-bottom-right-radius:4px;' );
+ }
- public function testItRendersBackgroundColorSetBySlug(): void {
- unset($this->parsedButton['attrs']['style']['color']);
- unset($this->parsedButton['attrs']['style']['spacing']['padding']);
- $this->parsedButton['attrs']['backgroundColor'] = 'black';
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- // For other blocks this is handled by CSS-inliner, but for button we need to handle it manually
- // because of special email HTML markup
- verify($output)->stringContainsString('background-color:#000000;');
- }
+ public function testItRendersBackgroundColorSetBySlug(): void {
+ unset( $this->parsedButton['attrs']['style']['color'] );
+ unset( $this->parsedButton['attrs']['style']['spacing']['padding'] );
+ $this->parsedButton['attrs']['backgroundColor'] = 'black';
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ // For other blocks this is handled by CSS-inliner, but for button we need to handle it manually
+ // because of special email HTML markup
+ verify( $output )->stringContainsString( 'background-color:#000000;' );
+ }
- public function testItRendersFontColorSetBySlug(): void {
- unset($this->parsedButton['attrs']['style']['color']);
- unset($this->parsedButton['attrs']['style']['spacing']['padding']);
- $this->parsedButton['attrs']['textColor'] = 'white';
- $output = $this->buttonRenderer->render($this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController);
- // For other blocks this is handled by CSS-inliner, but for button we need to handle it manually
- // because of special email HTML markup
- verify($output)->stringContainsString('color:#fff');
- }
+ public function testItRendersFontColorSetBySlug(): void {
+ unset( $this->parsedButton['attrs']['style']['color'] );
+ unset( $this->parsedButton['attrs']['style']['spacing']['padding'] );
+ $this->parsedButton['attrs']['textColor'] = 'white';
+ $output = $this->buttonRenderer->render( $this->parsedButton['innerHTML'], $this->parsedButton, $this->settingsController );
+ // For other blocks this is handled by CSS-inliner, but for button we need to handle it manually
+ // because of special email HTML markup
+ verify( $output )->stringContainsString( 'color:#fff' );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Column_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Column_Test.php
index 453f2993d5..1ba01fde71 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Column_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Column_Test.php
@@ -6,138 +6,138 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Column_Test extends \MailPoetTest {
- /** @var Column */
- private $columnRenderer;
+ /** @var Column */
+ private $columnRenderer;
- /** @var array */
- private $parsedColumn = [
- 'blockName' => 'core/column',
- 'email_attrs' => [
- 'width' => '300px',
- ],
- 'attrs' => [],
- 'innerBlocks' => [
- 0 => [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- 'innerHTML' => 'Column content ',
- 'innerContent' => [
- 0 => 'Column content ',
- ],
- ],
- ],
- 'innerHTML' => '',
- 'innerContent' => [
- 0 => '',
- 1 => null,
- 2 => ' ',
- ],
- ];
+ /** @var array */
+ private $parsedColumn = array(
+ 'blockName' => 'core/column',
+ 'email_attrs' => array(
+ 'width' => '300px',
+ ),
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ 0 => array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'Column content ',
+ 'innerContent' => array(
+ 0 => 'Column content ',
+ ),
+ ),
+ ),
+ 'innerHTML' => '',
+ 'innerContent' => array(
+ 0 => '',
+ 1 => null,
+ 2 => ' ',
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->columnRenderer = new Column();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->columnRenderer = new Column();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersColumnContent() {
- $rendered = $this->columnRenderer->render('', $this->parsedColumn, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('Column content', $rendered);
- }
+ public function testItRendersColumnContent() {
+ $rendered = $this->columnRenderer->render( '', $this->parsedColumn, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'Column content', $rendered );
+ }
- public function testItContainsColumnsStyles(): void {
- $parsedColumn = $this->parsedColumn;
- $parsedColumn['attrs'] = [
- 'style' => [
- 'border' => [
- 'bottom' => [
- 'color' => '#111111',
- 'width' => '1px',
- ],
- 'left' => [
- 'color' => '#222222',
- 'width' => '2px',
- ],
- 'right' => [
- 'color' => '#333333',
- 'width' => '3px',
- ],
- 'top' => [
- 'color' => '#444444',
- 'width' => '4px',
- ],
- 'radius' => [
- 'bottomLeft' => '5px',
- 'bottomRight' => '10px',
- 'topLeft' => '15px',
- 'topRight' => '20px',
- ],
- ],
- 'color' => [
- 'background' => '#abcdef',
- ],
- 'spacing' => [
- 'padding' => [
- 'bottom' => '5px',
- 'left' => '15px',
- 'right' => '20px',
- 'top' => '10px',
- ],
- ],
- ],
- ];
- $rendered = $this->columnRenderer->render('', $parsedColumn, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('background-color:#abcdef;', $rendered);
- $this->assertStringContainsString('border-bottom-left-radius:5px;', $rendered);
- $this->assertStringContainsString('border-bottom-right-radius:10px;', $rendered);
- $this->assertStringContainsString('border-top-left-radius:15px;', $rendered);
- $this->assertStringContainsString('border-top-right-radius:20px;', $rendered);
- $this->assertStringContainsString('border-top-color:#444444;', $rendered);
- $this->assertStringContainsString('border-top-width:4px;', $rendered);
- $this->assertStringContainsString('border-right-color:#333333;', $rendered);
- $this->assertStringContainsString('border-right-width:3px;', $rendered);
- $this->assertStringContainsString('border-bottom-color:#111111;', $rendered);
- $this->assertStringContainsString('border-bottom-width:1px;', $rendered);
- $this->assertStringContainsString('border-left-color:#222222;', $rendered);
- $this->assertStringContainsString('border-left-width:2px;', $rendered);
- $this->assertStringContainsString('border-style:solid;', $rendered);
- $this->assertStringContainsString('padding-bottom:5px;', $rendered);
- $this->assertStringContainsString('padding-left:15px;', $rendered);
- $this->assertStringContainsString('padding-right:20px;', $rendered);
- $this->assertStringContainsString('padding-top:10px;', $rendered);
- $this->assertStringContainsString('vertical-align:top;', $rendered); // Check for the default value of vertical alignment
- }
+ public function testItContainsColumnsStyles(): void {
+ $parsedColumn = $this->parsedColumn;
+ $parsedColumn['attrs'] = array(
+ 'style' => array(
+ 'border' => array(
+ 'bottom' => array(
+ 'color' => '#111111',
+ 'width' => '1px',
+ ),
+ 'left' => array(
+ 'color' => '#222222',
+ 'width' => '2px',
+ ),
+ 'right' => array(
+ 'color' => '#333333',
+ 'width' => '3px',
+ ),
+ 'top' => array(
+ 'color' => '#444444',
+ 'width' => '4px',
+ ),
+ 'radius' => array(
+ 'bottomLeft' => '5px',
+ 'bottomRight' => '10px',
+ 'topLeft' => '15px',
+ 'topRight' => '20px',
+ ),
+ ),
+ 'color' => array(
+ 'background' => '#abcdef',
+ ),
+ 'spacing' => array(
+ 'padding' => array(
+ 'bottom' => '5px',
+ 'left' => '15px',
+ 'right' => '20px',
+ 'top' => '10px',
+ ),
+ ),
+ ),
+ );
+ $rendered = $this->columnRenderer->render( '', $parsedColumn, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'background-color:#abcdef;', $rendered );
+ $this->assertStringContainsString( 'border-bottom-left-radius:5px;', $rendered );
+ $this->assertStringContainsString( 'border-bottom-right-radius:10px;', $rendered );
+ $this->assertStringContainsString( 'border-top-left-radius:15px;', $rendered );
+ $this->assertStringContainsString( 'border-top-right-radius:20px;', $rendered );
+ $this->assertStringContainsString( 'border-top-color:#444444;', $rendered );
+ $this->assertStringContainsString( 'border-top-width:4px;', $rendered );
+ $this->assertStringContainsString( 'border-right-color:#333333;', $rendered );
+ $this->assertStringContainsString( 'border-right-width:3px;', $rendered );
+ $this->assertStringContainsString( 'border-bottom-color:#111111;', $rendered );
+ $this->assertStringContainsString( 'border-bottom-width:1px;', $rendered );
+ $this->assertStringContainsString( 'border-left-color:#222222;', $rendered );
+ $this->assertStringContainsString( 'border-left-width:2px;', $rendered );
+ $this->assertStringContainsString( 'border-style:solid;', $rendered );
+ $this->assertStringContainsString( 'padding-bottom:5px;', $rendered );
+ $this->assertStringContainsString( 'padding-left:15px;', $rendered );
+ $this->assertStringContainsString( 'padding-right:20px;', $rendered );
+ $this->assertStringContainsString( 'padding-top:10px;', $rendered );
+ $this->assertStringContainsString( 'vertical-align:top;', $rendered ); // Check for the default value of vertical alignment
+ }
- public function testItContainsExpectedVerticalAlignment(): void {
- $parsedColumn = $this->parsedColumn;
- $parsedColumn['attrs']['verticalAlignment'] = 'bottom';
- $rendered = $this->columnRenderer->render('', $parsedColumn, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('vertical-align:bottom;', $rendered);
- }
+ public function testItContainsExpectedVerticalAlignment(): void {
+ $parsedColumn = $this->parsedColumn;
+ $parsedColumn['attrs']['verticalAlignment'] = 'bottom';
+ $rendered = $this->columnRenderer->render( '', $parsedColumn, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'vertical-align:bottom;', $rendered );
+ }
- public function testItSetsCustomColorAndBackground(): void {
- $parsedColumn = $this->parsedColumn;
- $parsedColumn['attrs']['style']['color']['text'] = '#123456';
- $parsedColumn['attrs']['style']['color']['background'] = '#654321';
- $rendered = $this->columnRenderer->render('', $parsedColumn, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('color:#123456;', $rendered);
- $this->assertStringContainsString('background-color:#654321;', $rendered);
- }
+ public function testItSetsCustomColorAndBackground(): void {
+ $parsedColumn = $this->parsedColumn;
+ $parsedColumn['attrs']['style']['color']['text'] = '#123456';
+ $parsedColumn['attrs']['style']['color']['background'] = '#654321';
+ $rendered = $this->columnRenderer->render( '', $parsedColumn, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'color:#123456;', $rendered );
+ $this->assertStringContainsString( 'background-color:#654321;', $rendered );
+ }
- public function testItPreservesClassesSetByEditor(): void {
- $parsedColumn = $this->parsedColumn;
- $content = '';
- $parsedColumn['attrs']['style']['color']['background'] = '#654321';
- $rendered = $this->columnRenderer->render($content, $parsedColumn, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('wp-block-column editor-class-1 another-class', $rendered);
- }
+ public function testItPreservesClassesSetByEditor(): void {
+ $parsedColumn = $this->parsedColumn;
+ $content = '';
+ $parsedColumn['attrs']['style']['color']['background'] = '#654321';
+ $rendered = $this->columnRenderer->render( $content, $parsedColumn, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'wp-block-column editor-class-1 another-class', $rendered );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Columns_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Columns_Test.php
index a390e8885d..bd63ba2f1b 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Columns_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Columns_Test.php
@@ -6,106 +6,106 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Columns_Test extends \MailPoetTest {
- /** @var Columns */
- private $columnsRenderer;
+ /** @var Columns */
+ private $columnsRenderer;
- /** @var array */
- private $parsedColumns = [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'email_attrs' => [
- 'width' => '784px',
- ],
- 'innerHTML' => '',
- 'innerBlocks' => [
- 0 => [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- 0 => [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- 'innerHTML' => 'Column 1 ',
- 'innerContent' => [
- 0 => 'Column 1 ',
- ],
- ],
- ],
- 'innerHTML' => '',
- 'innerContent' => [
- 0 => '',
- 1 => null,
- 2 => ' ',
- ],
- ],
- ],
- ];
+ /** @var array */
+ private $parsedColumns = array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'email_attrs' => array(
+ 'width' => '784px',
+ ),
+ 'innerHTML' => '',
+ 'innerBlocks' => array(
+ 0 => array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ 0 => array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'Column 1 ',
+ 'innerContent' => array(
+ 0 => 'Column 1 ',
+ ),
+ ),
+ ),
+ 'innerHTML' => '',
+ 'innerContent' => array(
+ 0 => '',
+ 1 => null,
+ 2 => ' ',
+ ),
+ ),
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->columnsRenderer = new Columns();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->columnsRenderer = new Columns();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersInnerColumn() {
- $rendered = $this->columnsRenderer->render('', $this->parsedColumns, $this->settingsController);
- verify($rendered)->stringContainsString('Column 1');
- }
+ public function testItRendersInnerColumn() {
+ $rendered = $this->columnsRenderer->render( '', $this->parsedColumns, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'Column 1' );
+ }
- public function testItContainsColumnsStyles(): void {
- $parsedColumns = $this->parsedColumns;
- $parsedColumns['attrs'] = [
- 'style' => [
- 'border' => [
- 'color' => '#123456',
- 'radius' => '10px',
- 'width' => '2px',
- ],
- 'color' => [
- 'background' => '#abcdef',
- ],
- 'spacing' => [
- 'padding' => [
- 'bottom' => '5px',
- 'left' => '15px',
- 'right' => '20px',
- 'top' => '10px',
- ],
- ],
- ],
- ];
- $rendered = $this->columnsRenderer->render('', $parsedColumns, $this->settingsController);
- verify($rendered)->stringContainsString('background-color:#abcdef;');
- verify($rendered)->stringContainsString('border-color:#123456;');
- verify($rendered)->stringContainsString('border-radius:10px;');
- verify($rendered)->stringContainsString('border-width:2px;');
- verify($rendered)->stringContainsString('border-style:solid;');
- verify($rendered)->stringContainsString('padding-bottom:5px;');
- verify($rendered)->stringContainsString('padding-left:15px;');
- verify($rendered)->stringContainsString('padding-right:20px;');
- verify($rendered)->stringContainsString('padding-top:10px;');
- }
+ public function testItContainsColumnsStyles(): void {
+ $parsedColumns = $this->parsedColumns;
+ $parsedColumns['attrs'] = array(
+ 'style' => array(
+ 'border' => array(
+ 'color' => '#123456',
+ 'radius' => '10px',
+ 'width' => '2px',
+ ),
+ 'color' => array(
+ 'background' => '#abcdef',
+ ),
+ 'spacing' => array(
+ 'padding' => array(
+ 'bottom' => '5px',
+ 'left' => '15px',
+ 'right' => '20px',
+ 'top' => '10px',
+ ),
+ ),
+ ),
+ );
+ $rendered = $this->columnsRenderer->render( '', $parsedColumns, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'background-color:#abcdef;' );
+ verify( $rendered )->stringContainsString( 'border-color:#123456;' );
+ verify( $rendered )->stringContainsString( 'border-radius:10px;' );
+ verify( $rendered )->stringContainsString( 'border-width:2px;' );
+ verify( $rendered )->stringContainsString( 'border-style:solid;' );
+ verify( $rendered )->stringContainsString( 'padding-bottom:5px;' );
+ verify( $rendered )->stringContainsString( 'padding-left:15px;' );
+ verify( $rendered )->stringContainsString( 'padding-right:20px;' );
+ verify( $rendered )->stringContainsString( 'padding-top:10px;' );
+ }
- public function testItSetsCustomColorAndBackground(): void {
- $parsedColumns = $this->parsedColumns;
- $parsedColumns['attrs']['style']['color']['text'] = '#123456';
- $parsedColumns['attrs']['style']['color']['background'] = '#654321';
- $rendered = $this->columnsRenderer->render('', $parsedColumns, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('color:#123456;', $rendered);
- $this->assertStringContainsString('background-color:#654321;', $rendered);
- }
+ public function testItSetsCustomColorAndBackground(): void {
+ $parsedColumns = $this->parsedColumns;
+ $parsedColumns['attrs']['style']['color']['text'] = '#123456';
+ $parsedColumns['attrs']['style']['color']['background'] = '#654321';
+ $rendered = $this->columnsRenderer->render( '', $parsedColumns, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'color:#123456;', $rendered );
+ $this->assertStringContainsString( 'background-color:#654321;', $rendered );
+ }
- public function testItPreservesClassesSetByEditor(): void {
- $parsedColumns = $this->parsedColumns;
- $content = '';
- $parsedColumns['attrs']['style']['color']['background'] = '#654321';
- $rendered = $this->columnsRenderer->render($content, $parsedColumns, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('wp-block-columns editor-class-1 another-class', $rendered);
- }
+ public function testItPreservesClassesSetByEditor(): void {
+ $parsedColumns = $this->parsedColumns;
+ $content = '';
+ $parsedColumns['attrs']['style']['color']['background'] = '#654321';
+ $rendered = $this->columnsRenderer->render( $content, $parsedColumns, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'wp-block-columns editor-class-1 another-class', $rendered );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Heading_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Heading_Test.php
index 3c96976d09..f1bda9644b 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Heading_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Heading_Test.php
@@ -6,67 +6,67 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Heading_Test extends \MailPoetTest {
- /** @var Text */
- private $headingRenderer;
+ /** @var Text */
+ private $headingRenderer;
- /** @var array */
- private $parsedHeading = [
- 'blockName' => 'core/heading',
- 'attrs' => [
- 'level' => 1,
- 'backgroundColor' => 'vivid-red',
- 'textColor' => 'pale-cyan-blue',
- 'textAlign' => 'center',
- 'style' => [
- 'typography' => [
- 'textTransform' => 'lowercase',
- 'fontSize' => '24px',
- ],
- ],
- ],
- 'email_attrs' => [
- 'width' => '640px',
- ],
- 'innerBlocks' => [],
- 'innerHTML' => 'This is Heading 1',
- 'innerContent' => [
- 0 => 'This is Heading 1',
- ],
- ];
+ /** @var array */
+ private $parsedHeading = array(
+ 'blockName' => 'core/heading',
+ 'attrs' => array(
+ 'level' => 1,
+ 'backgroundColor' => 'vivid-red',
+ 'textColor' => 'pale-cyan-blue',
+ 'textAlign' => 'center',
+ 'style' => array(
+ 'typography' => array(
+ 'textTransform' => 'lowercase',
+ 'fontSize' => '24px',
+ ),
+ ),
+ ),
+ 'email_attrs' => array(
+ 'width' => '640px',
+ ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'This is Heading 1',
+ 'innerContent' => array(
+ 0 => 'This is Heading 1',
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->headingRenderer = new Text();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->headingRenderer = new Text();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersContent(): void {
- $rendered = $this->headingRenderer->render('This is Heading 1', $this->parsedHeading, $this->settingsController);
- verify($rendered)->stringContainsString('This is Heading 1');
- verify($rendered)->stringContainsString('width:100%;');
- verify($rendered)->stringContainsString('font-size:24px;');
- verify($rendered)->stringNotContainsString('width:640px;');
- }
+ public function testItRendersContent(): void {
+ $rendered = $this->headingRenderer->render( 'This is Heading 1', $this->parsedHeading, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'This is Heading 1' );
+ verify( $rendered )->stringContainsString( 'width:100%;' );
+ verify( $rendered )->stringContainsString( 'font-size:24px;' );
+ verify( $rendered )->stringNotContainsString( 'width:640px;' );
+ }
- public function testItRendersBlockAttributes(): void {
- $rendered = $this->headingRenderer->render('This is Heading 1', $this->parsedHeading, $this->settingsController);
- verify($rendered)->stringContainsString('text-transform:lowercase;');
- verify($rendered)->stringContainsString('text-align:center;');
- }
+ public function testItRendersBlockAttributes(): void {
+ $rendered = $this->headingRenderer->render( 'This is Heading 1', $this->parsedHeading, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'text-transform:lowercase;' );
+ verify( $rendered )->stringContainsString( 'text-align:center;' );
+ }
- public function testItRendersCustomSetColors(): void {
- $this->parsedHeading['attrs']['style']['color']['background'] = '#000000';
- $this->parsedHeading['attrs']['style']['color']['text'] = '#ff0000';
- $rendered = $this->headingRenderer->render('This is Heading 1', $this->parsedHeading, $this->settingsController);
- verify($rendered)->stringContainsString('background-color:#000000');
- verify($rendered)->stringContainsString('color:#ff0000;');
- }
+ public function testItRendersCustomSetColors(): void {
+ $this->parsedHeading['attrs']['style']['color']['background'] = '#000000';
+ $this->parsedHeading['attrs']['style']['color']['text'] = '#ff0000';
+ $rendered = $this->headingRenderer->render( 'This is Heading 1', $this->parsedHeading, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'background-color:#000000' );
+ verify( $rendered )->stringContainsString( 'color:#ff0000;' );
+ }
- public function testItReplacesFluidFontSizeInContent(): void {
- $rendered = $this->headingRenderer->render('This is Heading 1', $this->parsedHeading, $this->settingsController);
- verify($rendered)->stringContainsString('font-size:24px');
- }
+ public function testItReplacesFluidFontSizeInContent(): void {
+ $rendered = $this->headingRenderer->render( 'This is Heading 1', $this->parsedHeading, $this->settingsController );
+ verify( $rendered )->stringContainsString( 'font-size:24px' );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Image_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Image_Test.php
index ae2fb12ff7..020a61b038 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Image_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Image_Test.php
@@ -6,135 +6,145 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Image_Test extends \MailPoetTest {
- /** @var Image */
- private $imageRenderer;
+ /** @var Image */
+ private $imageRenderer;
- private $imageContent = '
+ private $imageContent = '
';
- /** @var array */
- private $parsedImage = [
- 'blockName' => 'core/image',
- 'attrs' => [
- 'align' => 'left',
- 'id' => 1,
- 'scale' => 'cover',
- 'sizeSlug' => 'full',
- 'linkDestination' => 'none',
- 'className' => 'is-style-default',
- 'width' => '640px',
- ],
- 'innerBlocks' => [],
- 'innerHTML' => '',
- 'innerContent' => [],
- ];
+ /** @var array */
+ private $parsedImage = array(
+ 'blockName' => 'core/image',
+ 'attrs' => array(
+ 'align' => 'left',
+ 'id' => 1,
+ 'scale' => 'cover',
+ 'sizeSlug' => 'full',
+ 'linkDestination' => 'none',
+ 'className' => 'is-style-default',
+ 'width' => '640px',
+ ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => '',
+ 'innerContent' => array(),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->imageRenderer = new Image();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->imageRenderer = new Image();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersMandatoryImageStyles(): void {
- $parsedImage = $this->parsedImage;
- $parsedImage['innerHTML'] = $this->imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
+ public function testItRendersMandatoryImageStyles(): void {
+ $parsedImage = $this->parsedImage;
+ $parsedImage['innerHTML'] = $this->imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
- $rendered = $this->imageRenderer->render($this->imageContent, $parsedImage, $this->settingsController);
- $this->assertStringNotContainsString('assertStringNotContainsString('assertStringNotContainsString('', $rendered);
- $this->assertStringNotContainsString('', $rendered);
- $this->assertStringNotContainsString('srcset', $rendered);
- $this->assertStringContainsString('width="640"', $rendered);
- $this->assertStringContainsString('width:640px;', $rendered);
- $this->assertStringContainsString(' imageRenderer->render( $this->imageContent, $parsedImage, $this->settingsController );
+ $this->assertStringNotContainsString( 'assertStringNotContainsString( 'assertStringNotContainsString( '', $rendered );
+ $this->assertStringNotContainsString( '', $rendered );
+ $this->assertStringNotContainsString( 'srcset', $rendered );
+ $this->assertStringContainsString( 'width="640"', $rendered );
+ $this->assertStringContainsString( 'width:640px;', $rendered );
+ $this->assertStringContainsString( ' parsedImage;
- $parsedImage['attrs']['className'] = 'is-style-rounded';
- $parsedImage['innerHTML'] = $this->imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
+ public function testItRendersBorderRadiusStyle(): void {
+ $parsedImage = $this->parsedImage;
+ $parsedImage['attrs']['className'] = 'is-style-rounded';
+ $parsedImage['innerHTML'] = $this->imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
- $rendered = $this->imageRenderer->render($this->imageContent, $parsedImage, $this->settingsController);
- $this->assertStringNotContainsString('assertStringNotContainsString('assertStringNotContainsString('', $rendered);
- $this->assertStringNotContainsString('', $rendered);
- $this->assertStringContainsString('width="640"', $rendered);
- $this->assertStringContainsString('width:640px;', $rendered);
- $this->assertStringContainsString(' assertStringContainsString('border-radius: 9999px;', $rendered);
- }
+ $rendered = $this->imageRenderer->render( $this->imageContent, $parsedImage, $this->settingsController );
+ $this->assertStringNotContainsString( 'assertStringNotContainsString( 'assertStringNotContainsString( '', $rendered );
+ $this->assertStringNotContainsString( '', $rendered );
+ $this->assertStringContainsString( 'width="640"', $rendered );
+ $this->assertStringContainsString( 'width:640px;', $rendered );
+ $this->assertStringContainsString( ' assertStringContainsString( 'border-radius: 9999px;', $rendered );
+ }
- public function testItRendersCaption(): void {
- $imageContent = str_replace('', 'Caption', $this->imageContent);
- $parsedImage = $this->parsedImage;
- $parsedImage['innerHTML'] = $imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
+ public function testItRendersCaption(): void {
+ $imageContent = str_replace( '', 'Caption', $this->imageContent );
+ $parsedImage = $this->parsedImage;
+ $parsedImage['innerHTML'] = $imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
- $rendered = $this->imageRenderer->render($imageContent, $parsedImage, $this->settingsController);
- $this->assertStringContainsString('>Caption', $rendered);
- $this->assertStringContainsString('text-align:center;', $rendered);
- }
+ $rendered = $this->imageRenderer->render( $imageContent, $parsedImage, $this->settingsController );
+ $this->assertStringContainsString( '>Caption', $rendered );
+ $this->assertStringContainsString( 'text-align:center;', $rendered );
+ }
- public function testItRendersImageAlignment(): void {
- $imageContent = str_replace('style=""', 'style="width:400px;height:300px;"', $this->imageContent);
- $parsedImage = $this->parsedImage;
- $parsedImage['attrs']['align'] = 'center';
- $parsedImage['attrs']['width'] = '400px';
- $parsedImage['innerHTML'] = $imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
+ public function testItRendersImageAlignment(): void {
+ $imageContent = str_replace( 'style=""', 'style="width:400px;height:300px;"', $this->imageContent );
+ $parsedImage = $this->parsedImage;
+ $parsedImage['attrs']['align'] = 'center';
+ $parsedImage['attrs']['width'] = '400px';
+ $parsedImage['innerHTML'] = $imageContent; // To avoid repetition of the image content in the test we need to add it to the parsed block
- $rendered = $this->imageRenderer->render($imageContent, $parsedImage, $this->settingsController);
- $this->assertStringContainsString('align="center"', $rendered);
- $this->assertStringContainsString('width="400"', $rendered);
- $this->assertStringContainsString('height="300"', $rendered);
- $this->assertStringContainsString('height:300px;', $rendered);
- $this->assertStringContainsString('width:400px;', $rendered);
- }
+ $rendered = $this->imageRenderer->render( $imageContent, $parsedImage, $this->settingsController );
+ $this->assertStringContainsString( 'align="center"', $rendered );
+ $this->assertStringContainsString( 'width="400"', $rendered );
+ $this->assertStringContainsString( 'height="300"', $rendered );
+ $this->assertStringContainsString( 'height:300px;', $rendered );
+ $this->assertStringContainsString( 'width:400px;', $rendered );
+ }
- public function testItRendersBorders(): void {
- $imageContent = $this->imageContent;
- $parsedImage = $this->parsedImage;
- $parsedImage['attrs']['style']['border'] = [
- 'width' => '10px',
- 'color' => '#000001',
- 'radius' => '20px',
- ];
+ public function testItRendersBorders(): void {
+ $imageContent = $this->imageContent;
+ $parsedImage = $this->parsedImage;
+ $parsedImage['attrs']['style']['border'] = array(
+ 'width' => '10px',
+ 'color' => '#000001',
+ 'radius' => '20px',
+ );
- $rendered = $this->imageRenderer->render($imageContent, $parsedImage, $this->settingsController);
- $html = new \WP_HTML_Tag_Processor($rendered);
- // Border is rendered on the wrapping table cell
- $html->next_tag(['tag_name' => 'td', 'class_name' => 'email-image-cell']);
- $tableCellStyle = $html->get_attribute('style');
- $this->assertStringContainsString('border-color:#000001', $tableCellStyle);
- $this->assertStringContainsString('border-radius:20px', $tableCellStyle);
- $this->assertStringContainsString('border-style:solid;', $tableCellStyle);
- $html->next_tag(['tag_name' => 'img']);
- $imgStyle = $html->get_attribute('style');
- $this->assertStringNotContainsString('border', $imgStyle);
- }
+ $rendered = $this->imageRenderer->render( $imageContent, $parsedImage, $this->settingsController );
+ $html = new \WP_HTML_Tag_Processor( $rendered );
+ // Border is rendered on the wrapping table cell
+ $html->next_tag(
+ array(
+ 'tag_name' => 'td',
+ 'class_name' => 'email-image-cell',
+ )
+ );
+ $tableCellStyle = $html->get_attribute( 'style' );
+ $this->assertStringContainsString( 'border-color:#000001', $tableCellStyle );
+ $this->assertStringContainsString( 'border-radius:20px', $tableCellStyle );
+ $this->assertStringContainsString( 'border-style:solid;', $tableCellStyle );
+ $html->next_tag( array( 'tag_name' => 'img' ) );
+ $imgStyle = $html->get_attribute( 'style' );
+ $this->assertStringNotContainsString( 'border', $imgStyle );
+ }
- public function testItMovesBorderRelatedClasses(): void {
- $imageContent = str_replace(' imageContent);
- $parsedImage = $this->parsedImage;
- $parsedImage['attrs']['style']['border'] = [
- 'width' => '10px',
- 'color' => '#000001',
- 'radius' => '20px',
- ];
+ public function testItMovesBorderRelatedClasses(): void {
+ $imageContent = str_replace( ' imageContent );
+ $parsedImage = $this->parsedImage;
+ $parsedImage['attrs']['style']['border'] = array(
+ 'width' => '10px',
+ 'color' => '#000001',
+ 'radius' => '20px',
+ );
- $rendered = $this->imageRenderer->render($imageContent, $parsedImage, $this->settingsController);
- $html = new \WP_HTML_Tag_Processor($rendered);
- // Border is rendered on the wrapping table cell and the border classes are moved to the wrapping table cell
- $html->next_tag(['tag_name' => 'td', 'class_name' => 'email-image-cell']);
- $tableCellClass = $html->get_attribute('class');
- $this->assertStringContainsString('has-border-red-color', $tableCellClass);
- $this->assertStringContainsString('has-border-color', $tableCellClass);
- $this->assertStringNotContainsString('custom-class', $tableCellClass);
- }
+ $rendered = $this->imageRenderer->render( $imageContent, $parsedImage, $this->settingsController );
+ $html = new \WP_HTML_Tag_Processor( $rendered );
+ // Border is rendered on the wrapping table cell and the border classes are moved to the wrapping table cell
+ $html->next_tag(
+ array(
+ 'tag_name' => 'td',
+ 'class_name' => 'email-image-cell',
+ )
+ );
+ $tableCellClass = $html->get_attribute( 'class' );
+ $this->assertStringContainsString( 'has-border-red-color', $tableCellClass );
+ $this->assertStringContainsString( 'has-border-color', $tableCellClass );
+ $this->assertStringNotContainsString( 'custom-class', $tableCellClass );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/List_Block_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/List_Block_Test.php
index 48129ef318..d9b45fd3dd 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/List_Block_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/List_Block_Test.php
@@ -6,74 +6,74 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class List_Block_Test extends \MailPoetTest {
- /** @var List_Block */
- private $listRenderer;
+ /** @var List_Block */
+ private $listRenderer;
- /** @var array */
- private $parsedList = [
- 'blockName' => 'core/list',
- 'attrs' => [],
- 'innerBlocks' => [
- 0 => [
- 'blockName' => 'core/list-item',
- 'attrs' => [],
- 'innerBlocks' => [],
- 'innerHTML' => 'Item 1',
- 'innerContent' => [
- 0 => 'Item 1',
- ],
- ],
- 1 => [
- 'blockName' => 'core/list-item',
- 'attrs' => [],
- 'innerBlocks' => [],
- 'innerHTML' => 'Item 2',
- 'innerContent' => [
- 0 => 'Item 2',
- ],
- ],
- ],
- 'innerHTML' => '',
- 'innerContent' => [
- 0 => '',
- ],
- ];
+ /** @var array */
+ private $parsedList = array(
+ 'blockName' => 'core/list',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ 0 => array(
+ 'blockName' => 'core/list-item',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'Item 1',
+ 'innerContent' => array(
+ 0 => 'Item 1',
+ ),
+ ),
+ 1 => array(
+ 'blockName' => 'core/list-item',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'Item 2',
+ 'innerContent' => array(
+ 0 => 'Item 2',
+ ),
+ ),
+ ),
+ 'innerHTML' => '',
+ 'innerContent' => array(
+ 0 => '',
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->listRenderer = new List_Block();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->listRenderer = new List_Block();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersListContent(): void {
- $rendered = $this->listRenderer->render('', $this->parsedList, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('Item 1', $rendered);
- $this->assertStringContainsString('Item 2', $rendered);
- }
+ public function testItRendersListContent(): void {
+ $rendered = $this->listRenderer->render( '', $this->parsedList, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'Item 1', $rendered );
+ $this->assertStringContainsString( 'Item 2', $rendered );
+ }
- public function testItRendersFontSizeFromPreprocessor(): void {
- $parsedList = $this->parsedList;
- $parsedList['email_attrs'] = [
- 'font-size' => '20px',
- ];
- $rendered = $this->listRenderer->render('', $parsedList, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('Item 1', $rendered);
- $this->assertStringContainsString('Item 2', $rendered);
- $this->assertStringContainsString('font-size:20px;', $rendered);
- }
+ public function testItRendersFontSizeFromPreprocessor(): void {
+ $parsedList = $this->parsedList;
+ $parsedList['email_attrs'] = array(
+ 'font-size' => '20px',
+ );
+ $rendered = $this->listRenderer->render( '', $parsedList, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'Item 1', $rendered );
+ $this->assertStringContainsString( 'Item 2', $rendered );
+ $this->assertStringContainsString( 'font-size:20px;', $rendered );
+ }
- public function testItPreservesCustomSetColors(): void {
- $parsedList = $this->parsedList;
- $rendered = $this->listRenderer->render('', $parsedList, $this->settingsController);
- $this->checkValidHTML($rendered);
- $this->assertStringContainsString('color:#ff0000;', $rendered);
- $this->assertStringContainsString('background-color:#000000', $rendered);
- }
+ public function testItPreservesCustomSetColors(): void {
+ $parsedList = $this->parsedList;
+ $rendered = $this->listRenderer->render( '', $parsedList, $this->settingsController );
+ $this->checkValidHTML( $rendered );
+ $this->assertStringContainsString( 'color:#ff0000;', $rendered );
+ $this->assertStringContainsString( 'background-color:#000000', $rendered );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Paragraph_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Paragraph_Test.php
index 4cd15f3e8e..021eee9ac1 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Paragraph_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Blocks/Paragraph_Test.php
@@ -6,110 +6,110 @@ use MailPoet\EmailEditor\Engine\Email_Editor;
use MailPoet\EmailEditor\Engine\Settings_Controller;
class Paragraph_Test extends \MailPoetTest {
- /** @var Text */
- private $paragraphRenderer;
+ /** @var Text */
+ private $paragraphRenderer;
- /** @var array */
- private $parsedParagraph = [
- 'blockName' => 'core/paragraph',
- 'attrs' => [
- 'style' => [
- 'typography' => [
- 'fontSize' => '16px',
- ],
- ],
- ],
- 'innerBlocks' => [],
- 'innerHTML' => 'Lorem Ipsum ',
- 'innerContent' => [
- 0 => 'Lorem Ipsum ',
- ],
- ];
+ /** @var array */
+ private $parsedParagraph = array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(
+ 'style' => array(
+ 'typography' => array(
+ 'fontSize' => '16px',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ 'innerHTML' => 'Lorem Ipsum ',
+ 'innerContent' => array(
+ 0 => 'Lorem Ipsum ',
+ ),
+ );
- /** @var Settings_Controller */
- private $settingsController;
+ /** @var Settings_Controller */
+ private $settingsController;
- public function _before() {
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->paragraphRenderer = new Text();
- $this->settingsController = $this->diContainer->get(Settings_Controller::class);
- }
+ public function _before() {
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->paragraphRenderer = new Text();
+ $this->settingsController = $this->diContainer->get( Settings_Controller::class );
+ }
- public function testItRendersContent(): void {
- $rendered = $this->paragraphRenderer->render('Lorem Ipsum ', $this->parsedParagraph, $this->settingsController);
- $this->assertStringContainsString('width:100%', $rendered);
- $this->assertStringContainsString('Lorem Ipsum', $rendered);
- $this->assertStringContainsString('font-size:16px;', $rendered);
- $this->assertStringContainsString('text-align:left;', $rendered); // Check the default text-align
- $this->assertStringContainsString('align="left"', $rendered); // Check the default align
- }
+ public function testItRendersContent(): void {
+ $rendered = $this->paragraphRenderer->render( 'Lorem Ipsum ', $this->parsedParagraph, $this->settingsController );
+ $this->assertStringContainsString( 'width:100%', $rendered );
+ $this->assertStringContainsString( 'Lorem Ipsum', $rendered );
+ $this->assertStringContainsString( 'font-size:16px;', $rendered );
+ $this->assertStringContainsString( 'text-align:left;', $rendered ); // Check the default text-align
+ $this->assertStringContainsString( 'align="left"', $rendered ); // Check the default align
+ }
- public function testItRendersContentWithPadding(): void {
- $parsedParagraph = $this->parsedParagraph;
- $parsedParagraph['attrs']['style']['spacing']['padding']['top'] = '10px';
- $parsedParagraph['attrs']['style']['spacing']['padding']['right'] = '20px';
- $parsedParagraph['attrs']['style']['spacing']['padding']['bottom'] = '30px';
- $parsedParagraph['attrs']['style']['spacing']['padding']['left'] = '40px';
- $parsedParagraph['attrs']['align'] = 'center';
+ public function testItRendersContentWithPadding(): void {
+ $parsedParagraph = $this->parsedParagraph;
+ $parsedParagraph['attrs']['style']['spacing']['padding']['top'] = '10px';
+ $parsedParagraph['attrs']['style']['spacing']['padding']['right'] = '20px';
+ $parsedParagraph['attrs']['style']['spacing']['padding']['bottom'] = '30px';
+ $parsedParagraph['attrs']['style']['spacing']['padding']['left'] = '40px';
+ $parsedParagraph['attrs']['align'] = 'center';
- $rendered = $this->paragraphRenderer->render('Lorem Ipsum ', $parsedParagraph, $this->settingsController);
- $this->assertStringContainsString('padding-top:10px;', $rendered);
- $this->assertStringContainsString('padding-right:20px;', $rendered);
- $this->assertStringContainsString('padding-bottom:30px;', $rendered);
- $this->assertStringContainsString('padding-left:40px;', $rendered);
- $this->assertStringContainsString('text-align:center;', $rendered);
- $this->assertStringContainsString('align="center"', $rendered);
- $this->assertStringContainsString('Lorem Ipsum', $rendered);
- }
+ $rendered = $this->paragraphRenderer->render( 'Lorem Ipsum ', $parsedParagraph, $this->settingsController );
+ $this->assertStringContainsString( 'padding-top:10px;', $rendered );
+ $this->assertStringContainsString( 'padding-right:20px;', $rendered );
+ $this->assertStringContainsString( 'padding-bottom:30px;', $rendered );
+ $this->assertStringContainsString( 'padding-left:40px;', $rendered );
+ $this->assertStringContainsString( 'text-align:center;', $rendered );
+ $this->assertStringContainsString( 'align="center"', $rendered );
+ $this->assertStringContainsString( 'Lorem Ipsum', $rendered );
+ }
- public function testItRendersBorders(): void {
- $parsedParagraph = $this->parsedParagraph;
- $parsedParagraph['attrs']['style']['border']['width'] = '10px';
- $parsedParagraph['attrs']['style']['border']['color'] = '#000001';
- $parsedParagraph['attrs']['style']['border']['radius'] = '20px';
+ public function testItRendersBorders(): void {
+ $parsedParagraph = $this->parsedParagraph;
+ $parsedParagraph['attrs']['style']['border']['width'] = '10px';
+ $parsedParagraph['attrs']['style']['border']['color'] = '#000001';
+ $parsedParagraph['attrs']['style']['border']['radius'] = '20px';
- $content = 'Lorem Ipsum ';
- $parsedParagraph['innerHTML'] = $content;
- $parsedParagraph['innerContent'] = [$content];
+ $content = 'Lorem Ipsum ';
+ $parsedParagraph['innerHTML'] = $content;
+ $parsedParagraph['innerContent'] = array( $content );
- $rendered = $this->paragraphRenderer->render($content, $parsedParagraph, $this->settingsController);
- $html = new \WP_HTML_Tag_Processor($rendered);
- $html->next_tag(['tag_name' => 'table']);
- $tableStyle = $html->get_attribute('style');
- // Table needs to have border-collapse: separate to make border-radius work
- $this->assertStringContainsString('border-collapse: separate', $tableStyle);
- $html->next_tag(['tag_name' => 'td']);
- $tableCellStyle = $html->get_attribute('style');
- // Border styles are applied to the table cell
- $this->assertStringContainsString('border-color:#000001', $tableCellStyle);
- $this->assertStringContainsString('border-radius:20px', $tableCellStyle);
- $this->assertStringContainsString('border-width:10px', $tableCellStyle);
- $tableCellClasses = $html->get_attribute('class');
- $this->assertStringContainsString('has-border-color test-class has-red-border-color', $tableCellClasses);
- $html->next_tag(['tag_name' => 'p']);
- // There are no border styles on the paragraph
- $paragraphStyle = $html->get_attribute('style');
- $this->assertStringNotContainsString('border', $paragraphStyle);
- }
+ $rendered = $this->paragraphRenderer->render( $content, $parsedParagraph, $this->settingsController );
+ $html = new \WP_HTML_Tag_Processor( $rendered );
+ $html->next_tag( array( 'tag_name' => 'table' ) );
+ $tableStyle = $html->get_attribute( 'style' );
+ // Table needs to have border-collapse: separate to make border-radius work
+ $this->assertStringContainsString( 'border-collapse: separate', $tableStyle );
+ $html->next_tag( array( 'tag_name' => 'td' ) );
+ $tableCellStyle = $html->get_attribute( 'style' );
+ // Border styles are applied to the table cell
+ $this->assertStringContainsString( 'border-color:#000001', $tableCellStyle );
+ $this->assertStringContainsString( 'border-radius:20px', $tableCellStyle );
+ $this->assertStringContainsString( 'border-width:10px', $tableCellStyle );
+ $tableCellClasses = $html->get_attribute( 'class' );
+ $this->assertStringContainsString( 'has-border-color test-class has-red-border-color', $tableCellClasses );
+ $html->next_tag( array( 'tag_name' => 'p' ) );
+ // There are no border styles on the paragraph
+ $paragraphStyle = $html->get_attribute( 'style' );
+ $this->assertStringNotContainsString( 'border', $paragraphStyle );
+ }
- public function testItConvertsBlockTypography(): void {
- $parsedParagraph = $this->parsedParagraph;
- $parsedParagraph['attrs']['style']['typography'] = [
- 'textTransform' => 'uppercase',
- 'letterSpacing' => '1px',
- 'textDecoration' => 'underline',
- 'fontStyle' => 'italic',
- 'fontWeight' => 'bold',
- 'fontSize' => '20px',
- ];
+ public function testItConvertsBlockTypography(): void {
+ $parsedParagraph = $this->parsedParagraph;
+ $parsedParagraph['attrs']['style']['typography'] = array(
+ 'textTransform' => 'uppercase',
+ 'letterSpacing' => '1px',
+ 'textDecoration' => 'underline',
+ 'fontStyle' => 'italic',
+ 'fontWeight' => 'bold',
+ 'fontSize' => '20px',
+ );
- $rendered = $this->paragraphRenderer->render('Lorem Ipsum ', $parsedParagraph, $this->settingsController);
- $this->assertStringContainsString('text-transform:uppercase;', $rendered);
- $this->assertStringContainsString('letter-spacing:1px;', $rendered);
- $this->assertStringContainsString('text-decoration:underline;', $rendered);
- $this->assertStringContainsString('font-style:italic;', $rendered);
- $this->assertStringContainsString('font-weight:bold;', $rendered);
- $this->assertStringContainsString('font-size:20px;', $rendered);
- $this->assertStringContainsString('Lorem Ipsum', $rendered);
- }
+ $rendered = $this->paragraphRenderer->render( 'Lorem Ipsum ', $parsedParagraph, $this->settingsController );
+ $this->assertStringContainsString( 'text-transform:uppercase;', $rendered );
+ $this->assertStringContainsString( 'letter-spacing:1px;', $rendered );
+ $this->assertStringContainsString( 'text-decoration:underline;', $rendered );
+ $this->assertStringContainsString( 'font-style:italic;', $rendered );
+ $this->assertStringContainsString( 'font-weight:bold;', $rendered );
+ $this->assertStringContainsString( 'font-size:20px;', $rendered );
+ $this->assertStringContainsString( 'Lorem Ipsum', $rendered );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
index 3d677b9081..6329376434 100644
--- a/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
+++ b/packages/php/email-editor/tests/integration/Integrations/Core/Renderer/Renderer_Test.php
@@ -7,72 +7,83 @@ use MailPoet\EmailEditor\Engine\Renderer\Renderer;
use MailPoet\EmailEditor\Integrations\Core\Initializer;
class Renderer_Test extends \MailPoetTest {
- /** @var Renderer */
- private $renderer;
+ /** @var Renderer */
+ private $renderer;
- public function _before() {
- parent::_before();
- $this->renderer = $this->diContainer->get(Renderer::class);
- $this->diContainer->get(Email_Editor::class)->initialize();
- $this->diContainer->get(Initializer::class)->initialize();
- }
+ public function _before() {
+ parent::_before();
+ $this->renderer = $this->diContainer->get( Renderer::class );
+ $this->diContainer->get( Email_Editor::class )->initialize();
+ $this->diContainer->get( Initializer::class )->initialize();
+ }
- public function testItInlinesButtonDefaultStyles() {
- $emailPost = $this->tester->createPost([
- 'post_content' => '',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $buttonHtml = $this->extractBlockHtml($rendered['html'], 'wp-block-button', 'td');
- verify($buttonHtml)->stringContainsString('color: #fff');
- verify($buttonHtml)->stringContainsString('padding-bottom: .7em;');
- verify($buttonHtml)->stringContainsString('padding-left: 1.4em;');
- verify($buttonHtml)->stringContainsString('padding-right: 1.4em;');
- verify($buttonHtml)->stringContainsString('padding-top: .7em;');
- verify($buttonHtml)->stringContainsString('background-color: #32373c');
- }
+ public function testItInlinesButtonDefaultStyles() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => '',
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $buttonHtml = $this->extractBlockHtml( $rendered['html'], 'wp-block-button', 'td' );
+ verify( $buttonHtml )->stringContainsString( 'color: #fff' );
+ verify( $buttonHtml )->stringContainsString( 'padding-bottom: .7em;' );
+ verify( $buttonHtml )->stringContainsString( 'padding-left: 1.4em;' );
+ verify( $buttonHtml )->stringContainsString( 'padding-right: 1.4em;' );
+ verify( $buttonHtml )->stringContainsString( 'padding-top: .7em;' );
+ verify( $buttonHtml )->stringContainsString( 'background-color: #32373c' );
+ }
- public function testButtonDefaultStylesDontOverwriteUserSetStyles() {
- $emailPost = $this->tester->createPost([
- 'post_content' => '',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $buttonHtml = $this->extractBlockHtml($rendered['html'], 'wp-block-button', 'td');
- verify($buttonHtml)->stringContainsString('color: #0693e3');
- verify($buttonHtml)->stringContainsString('background-color: #ffffff');
- }
+ public function testButtonDefaultStylesDontOverwriteUserSetStyles() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => '',
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $buttonHtml = $this->extractBlockHtml( $rendered['html'], 'wp-block-button', 'td' );
+ verify( $buttonHtml )->stringContainsString( 'color: #0693e3' );
+ verify( $buttonHtml )->stringContainsString( 'background-color: #ffffff' );
+ }
- public function testItInlinesHeadingFontSize() {
- $emailPost = $this->tester->createPost([
- 'post_content' => 'Hello',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $headingHtml = $this->extractBlockHtml($rendered['html'], 'wp-block-heading', 'h1');
- verify($headingHtml)->stringContainsString('font-size: 42px'); // large is 42px in theme.json
- }
+ public function testItInlinesHeadingFontSize() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => 'Hello',
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $headingHtml = $this->extractBlockHtml( $rendered['html'], 'wp-block-heading', 'h1' );
+ verify( $headingHtml )->stringContainsString( 'font-size: 42px' ); // large is 42px in theme.json
+ }
- public function testItInlinesHeadingColors() {
- $emailPost = $this->tester->createPost([
- 'post_content' => 'Hello',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $headingWrapperStyle = $this->extractBlockStyle($rendered['html'], 'has-luminous-vivid-orange-color', 'td');
- verify($headingWrapperStyle)->stringContainsString('color: #ff6900'); // luminous-vivid-orange is #ff6900
- verify($headingWrapperStyle)->stringContainsString('background-color: #000'); // black is #000
- }
+ public function testItInlinesHeadingColors() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => 'Hello',
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $headingWrapperStyle = $this->extractBlockStyle( $rendered['html'], 'has-luminous-vivid-orange-color', 'td' );
+ verify( $headingWrapperStyle )->stringContainsString( 'color: #ff6900' ); // luminous-vivid-orange is #ff6900
+ verify( $headingWrapperStyle )->stringContainsString( 'background-color: #000' ); // black is #000
+ }
- public function testItInlinesParagraphColors() {
- $emailPost = $this->tester->createPost([
- 'post_content' => 'Hello ',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $paragraphWrapperStyle = $this->extractBlockStyle($rendered['html'], 'has-luminous-vivid-orange-color', 'td');
- verify($paragraphWrapperStyle)->stringContainsString('color: #ff6900'); // luminous-vivid-orange is #ff6900
- verify($paragraphWrapperStyle)->stringContainsString('background-color: #000'); // black is #000
- }
+ public function testItInlinesParagraphColors() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => 'Hello ',
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $paragraphWrapperStyle = $this->extractBlockStyle( $rendered['html'], 'has-luminous-vivid-orange-color', 'td' );
+ verify( $paragraphWrapperStyle )->stringContainsString( 'color: #ff6900' ); // luminous-vivid-orange is #ff6900
+ verify( $paragraphWrapperStyle )->stringContainsString( 'background-color: #000' ); // black is #000
+ }
- public function testItInlinesListColors() {
- $emailPost = $this->tester->createPost([
- 'post_content' => '
+ public function testItInlinesListColors() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => '
- Item 1
@@ -81,62 +92,67 @@ class Renderer_Test extends \MailPoetTest {
- Item 2
',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $listStyle = $this->extractBlockStyle($rendered['html'], 'has-luminous-vivid-orange-color', 'ul');
- verify($listStyle)->stringContainsString('color: #ff6900'); // luminous-vivid-orange is #ff6900
- verify($listStyle)->stringContainsString('background-color: #000'); // black is #000
- }
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $listStyle = $this->extractBlockStyle( $rendered['html'], 'has-luminous-vivid-orange-color', 'ul' );
+ verify( $listStyle )->stringContainsString( 'color: #ff6900' ); // luminous-vivid-orange is #ff6900
+ verify( $listStyle )->stringContainsString( 'background-color: #000' ); // black is #000
+ }
- public function testItInlinesColumnsColors() {
- $emailPost = $this->tester->createPost([
- 'post_content' => '
+ public function testItInlinesColumnsColors() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => '
',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $style = $this->extractBlockStyle($rendered['html'], 'wp-block-columns', 'table');
- verify($style)->stringContainsString('color: #ff6900'); // luminous-vivid-orange is #ff6900
- verify($style)->stringContainsString('background-color: #000'); // black is #000
- }
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $style = $this->extractBlockStyle( $rendered['html'], 'wp-block-columns', 'table' );
+ verify( $style )->stringContainsString( 'color: #ff6900' ); // luminous-vivid-orange is #ff6900
+ verify( $style )->stringContainsString( 'background-color: #000' ); // black is #000
+ }
- public function testItInlinesColumnColors() {
- $emailPost = $this->tester->createPost([
- 'post_content' => '
+ public function testItInlinesColumnColors() {
+ $emailPost = $this->tester->createPost(
+ array(
+ 'post_content' => '
',
- ]);
- $rendered = $this->renderer->render($emailPost, 'Subject', '', 'en');
- $style = $this->extractBlockStyle($rendered['html'], 'wp-block-column-test', 'td');
- verify($style)->stringContainsString('color: #ff6900'); // luminous-vivid-orange is #ff6900
- verify($style)->stringContainsString('background-color: #000'); // black is #000
- }
+ )
+ );
+ $rendered = $this->renderer->render( $emailPost, 'Subject', '', 'en' );
+ $style = $this->extractBlockStyle( $rendered['html'], 'wp-block-column-test', 'td' );
+ verify( $style )->stringContainsString( 'color: #ff6900' ); // luminous-vivid-orange is #ff6900
+ verify( $style )->stringContainsString( 'background-color: #000' ); // black is #000
+ }
- private function extractBlockHtml(string $html, string $blockClass, string $tag): string {
- $doc = new \DOMDocument();
- $doc->loadHTML($html);
- $xpath = new \DOMXPath($doc);
- $nodes = $xpath->query('//' . $tag . '[contains(@class, "' . $blockClass . '")]');
- $block = null;
- if (($nodes instanceof \DOMNodeList) && $nodes->length > 0) {
- $block = $nodes->item(0);
- }
- $this->assertInstanceOf(\DOMElement::class, $block);
- $this->assertInstanceOf(\DOMDocument::class, $block->ownerDocument);
- return (string)$block->ownerDocument->saveHTML($block);
- }
+ private function extractBlockHtml( string $html, string $blockClass, string $tag ): string {
+ $doc = new \DOMDocument();
+ $doc->loadHTML( $html );
+ $xpath = new \DOMXPath( $doc );
+ $nodes = $xpath->query( '//' . $tag . '[contains(@class, "' . $blockClass . '")]' );
+ $block = null;
+ if ( ( $nodes instanceof \DOMNodeList ) && $nodes->length > 0 ) {
+ $block = $nodes->item( 0 );
+ }
+ $this->assertInstanceOf( \DOMElement::class, $block );
+ $this->assertInstanceOf( \DOMDocument::class, $block->ownerDocument );
+ return (string) $block->ownerDocument->saveHTML( $block );
+ }
- private function extractBlockStyle(string $html, string $blockClass, string $tag): string {
- $doc = new \DOMDocument();
- $doc->loadHTML($html);
- $xpath = new \DOMXPath($doc);
- $nodes = $xpath->query('//' . $tag . '[contains(@class, "' . $blockClass . '")]');
- $block = null;
- if (($nodes instanceof \DOMNodeList) && $nodes->length > 0) {
- $block = $nodes->item(0);
- }
- $this->assertInstanceOf(\DOMElement::class, $block);
- return $block->getAttribute('style');
- }
+ private function extractBlockStyle( string $html, string $blockClass, string $tag ): string {
+ $doc = new \DOMDocument();
+ $doc->loadHTML( $html );
+ $xpath = new \DOMXPath( $doc );
+ $nodes = $xpath->query( '//' . $tag . '[contains(@class, "' . $blockClass . '")]' );
+ $block = null;
+ if ( ( $nodes instanceof \DOMNodeList ) && $nodes->length > 0 ) {
+ $block = $nodes->item( 0 );
+ }
+ $this->assertInstanceOf( \DOMElement::class, $block );
+ return $block->getAttribute( 'style' );
+ }
}
diff --git a/packages/php/email-editor/tests/integration/_bootstrap.php b/packages/php/email-editor/tests/integration/_bootstrap.php
index c2128250df..0500f5c3a0 100644
--- a/packages/php/email-editor/tests/integration/_bootstrap.php
+++ b/packages/php/email-editor/tests/integration/_bootstrap.php
@@ -24,12 +24,12 @@ use MailPoet\EmailEditor\Integrations\Core\Initializer;
use MailPoet\EmailEditor\Integrations\MailPoet\Blocks\BlockTypesController;
use MailPoet\EmailEditor\Utils\Cdn_Asset_Url;
-if ((boolean)getenv('MULTISITE') === true) {
- // REQUEST_URI needs to be set for WP to load the proper subsite where MailPoet is activated
- $_SERVER['REQUEST_URI'] = '/' . getenv('WP_TEST_MULTISITE_SLUG');
- $wpLoadFile = getenv('WP_ROOT_MULTISITE') . '/wp-load.php';
+if ( (bool) getenv( 'MULTISITE' ) === true ) {
+ // REQUEST_URI needs to be set for WP to load the proper subsite where MailPoet is activated
+ $_SERVER['REQUEST_URI'] = '/' . getenv( 'WP_TEST_MULTISITE_SLUG' );
+ $wpLoadFile = getenv( 'WP_ROOT_MULTISITE' ) . '/wp-load.php';
} else {
- $wpLoadFile = getenv('WP_ROOT') . '/wp-load.php';
+ $wpLoadFile = getenv( 'WP_ROOT' ) . '/wp-load.php';
}
/**
@@ -37,143 +37,209 @@ if ((boolean)getenv('MULTISITE') === true) {
* Note that the following are override in the docker-compose file
* WP_ROOT, WP_ROOT_MULTISITE, WP_TEST_MULTISITE_SLUG
*/
-$console = new \Codeception\Lib\Console\Output([]);
-$console->writeln('Loading WP core... (' . $wpLoadFile . ')');
-require_once($wpLoadFile);
+$console = new \Codeception\Lib\Console\Output( array() );
+$console->writeln( 'Loading WP core... (' . $wpLoadFile . ')' );
+require_once $wpLoadFile;
/**
* @property IntegrationTester $tester
*/
abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
- public Container $diContainer;
+ public Container $diContainer;
- protected $backupGlobals = false;
- protected $backupStaticAttributes = false;
- protected $runTestInSeparateProcess = false;
- protected $preserveGlobalState = false;
+ protected $backupGlobals = false;
+ protected $backupStaticAttributes = false;
+ protected $runTestInSeparateProcess = false;
+ protected $preserveGlobalState = false;
- public function setUp(): void {
- $this->initContainer();
- parent::setUp();
- }
+ public function setUp(): void {
+ $this->initContainer();
+ parent::setUp();
+ }
- protected function checkValidHTML(string $html): void {
- $dom = new \DOMDocument();
- libxml_use_internal_errors(true);
- $dom->loadHTML($html);
+ protected function checkValidHTML( string $html ): void {
+ $dom = new \DOMDocument();
+ libxml_use_internal_errors( true );
+ $dom->loadHTML( $html );
- // Check for errors during parsing
- $errors = libxml_get_errors();
- libxml_clear_errors();
+ // Check for errors during parsing
+ $errors = libxml_get_errors();
+ libxml_clear_errors();
- $this->assertEmpty($errors, 'HTML is not valid: ' . $html);
- }
+ $this->assertEmpty( $errors, 'HTML is not valid: ' . $html );
+ }
- public function getServiceWithOverrides(string $id, array $overrides) {
- $instance = $this->diContainer->get($id);
- return Stub::copy($instance, $overrides);
- }
+ public function getServiceWithOverrides( string $id, array $overrides ) {
+ $instance = $this->diContainer->get( $id );
+ return Stub::copy( $instance, $overrides );
+ }
- protected function initContainer(): void {
- $container = new Container();
- // Start: MailPoet plugin dependencies
- $container->set(Initializer::class, function() {
- return new Initializer();
- });
- $container->set(Cdn_Asset_Url::class, function() {
- return new Cdn_Asset_Url('http://localhost');
- });
- $container->set(Email_Api_Controller::class, function() {
- return new Email_Api_Controller();
- });
- $container->set(BlockTypesController::class, function() {
- return $this->createMock(BlockTypesController::class);
- });
- // End: MailPoet plugin dependencies
- $container->set(Utils::class, function() {
- return new Utils();
- });
- $container->set(Theme_Controller::class, function() {
- return new Theme_Controller();
- });
- $container->set(Settings_Controller::class, function ($container) {
- return new Settings_Controller($container->get(Theme_Controller::class));
- });
- $container->set(Settings_Controller::class, function ($container) {
- return new Settings_Controller($container->get(Theme_Controller::class));
- });
- $container->set(Templates::class, function ($container) {
- return new Templates($container->get(Utils::class));
- });
- $container->set(Template_Preview::class, function ($container) {
- return new Template_Preview(
- $container->get(Theme_Controller::class),
- $container->get(Settings_Controller::class),
- $container->get(Templates::class),
- );
- });
- $container->set(Patterns::class, function ($container) {
- return new Patterns(
- $container->get(Cdn_Asset_Url::class),
- );
- });
- $container->set(Cleanup_Preprocessor::class, function () {
- return new Cleanup_Preprocessor();
- });
- $container->set(Blocks_Width_Preprocessor::class, function () {
- return new Blocks_Width_Preprocessor();
- });
- $container->set(Typography_Preprocessor::class, function ($container) {
- return new Typography_Preprocessor($container->get(Settings_Controller::class));
- });
- $container->set(Spacing_Preprocessor::class, function () {
- return new Spacing_Preprocessor();
- });
- $container->set(Highlighting_Postprocessor::class, function () {
- return new Highlighting_Postprocessor();
- });
- $container->set(Variables_Postprocessor::class, function ($container) {
- return new Variables_Postprocessor($container->get(Theme_Controller::class));
- });
- $container->set(Process_Manager::class, function ($container) {
- return new Process_Manager(
- $container->get(Cleanup_Preprocessor::class),
- $container->get(Blocks_Width_Preprocessor::class),
- $container->get(Typography_Preprocessor::class),
- $container->get(Spacing_Preprocessor::class),
- $container->get(Highlighting_Postprocessor::class),
- $container->get(Variables_Postprocessor::class),
- );
- });
- $container->set(Blocks_Registry::class, function() {
- return new Blocks_Registry();
- });
- $container->set(Content_Renderer::class, function ($container) {
- return new Content_Renderer(
- $container->get(Process_Manager::class),
- $container->get(Blocks_Registry::class),
- $container->get(Settings_Controller::class),
- $container->get(Theme_Controller::class),
- );
- });
- $container->set(Renderer::class, function ($container) {
- return new Renderer(
- $container->get(Content_Renderer::class),
- $container->get(Templates::class),
- $container->get(Theme_Controller::class),
- );
- });
- $container->set(Email_Editor::class, function ($container) {
- return new Email_Editor(
- $container->get(Email_Api_Controller::class),
- $container->get(Templates::class),
- $container->get(Template_Preview::class),
- $container->get(Patterns::class),
- $container->get(Settings_Controller::class),
- );
- });
+ protected function initContainer(): void {
+ $container = new Container();
+ // Start: MailPoet plugin dependencies
+ $container->set(
+ Initializer::class,
+ function () {
+ return new Initializer();
+ }
+ );
+ $container->set(
+ Cdn_Asset_Url::class,
+ function () {
+ return new Cdn_Asset_Url( 'http://localhost' );
+ }
+ );
+ $container->set(
+ Email_Api_Controller::class,
+ function () {
+ return new Email_Api_Controller();
+ }
+ );
+ $container->set(
+ BlockTypesController::class,
+ function () {
+ return $this->createMock( BlockTypesController::class );
+ }
+ );
+ // End: MailPoet plugin dependencies
+ $container->set(
+ Utils::class,
+ function () {
+ return new Utils();
+ }
+ );
+ $container->set(
+ Theme_Controller::class,
+ function () {
+ return new Theme_Controller();
+ }
+ );
+ $container->set(
+ Settings_Controller::class,
+ function ( $container ) {
+ return new Settings_Controller( $container->get( Theme_Controller::class ) );
+ }
+ );
+ $container->set(
+ Settings_Controller::class,
+ function ( $container ) {
+ return new Settings_Controller( $container->get( Theme_Controller::class ) );
+ }
+ );
+ $container->set(
+ Templates::class,
+ function ( $container ) {
+ return new Templates( $container->get( Utils::class ) );
+ }
+ );
+ $container->set(
+ Template_Preview::class,
+ function ( $container ) {
+ return new Template_Preview(
+ $container->get( Theme_Controller::class ),
+ $container->get( Settings_Controller::class ),
+ $container->get( Templates::class ),
+ );
+ }
+ );
+ $container->set(
+ Patterns::class,
+ function ( $container ) {
+ return new Patterns(
+ $container->get( Cdn_Asset_Url::class ),
+ );
+ }
+ );
+ $container->set(
+ Cleanup_Preprocessor::class,
+ function () {
+ return new Cleanup_Preprocessor();
+ }
+ );
+ $container->set(
+ Blocks_Width_Preprocessor::class,
+ function () {
+ return new Blocks_Width_Preprocessor();
+ }
+ );
+ $container->set(
+ Typography_Preprocessor::class,
+ function ( $container ) {
+ return new Typography_Preprocessor( $container->get( Settings_Controller::class ) );
+ }
+ );
+ $container->set(
+ Spacing_Preprocessor::class,
+ function () {
+ return new Spacing_Preprocessor();
+ }
+ );
+ $container->set(
+ Highlighting_Postprocessor::class,
+ function () {
+ return new Highlighting_Postprocessor();
+ }
+ );
+ $container->set(
+ Variables_Postprocessor::class,
+ function ( $container ) {
+ return new Variables_Postprocessor( $container->get( Theme_Controller::class ) );
+ }
+ );
+ $container->set(
+ Process_Manager::class,
+ function ( $container ) {
+ return new Process_Manager(
+ $container->get( Cleanup_Preprocessor::class ),
+ $container->get( Blocks_Width_Preprocessor::class ),
+ $container->get( Typography_Preprocessor::class ),
+ $container->get( Spacing_Preprocessor::class ),
+ $container->get( Highlighting_Postprocessor::class ),
+ $container->get( Variables_Postprocessor::class ),
+ );
+ }
+ );
+ $container->set(
+ Blocks_Registry::class,
+ function () {
+ return new Blocks_Registry();
+ }
+ );
+ $container->set(
+ Content_Renderer::class,
+ function ( $container ) {
+ return new Content_Renderer(
+ $container->get( Process_Manager::class ),
+ $container->get( Blocks_Registry::class ),
+ $container->get( Settings_Controller::class ),
+ $container->get( Theme_Controller::class ),
+ );
+ }
+ );
+ $container->set(
+ Renderer::class,
+ function ( $container ) {
+ return new Renderer(
+ $container->get( Content_Renderer::class ),
+ $container->get( Templates::class ),
+ $container->get( Theme_Controller::class ),
+ );
+ }
+ );
+ $container->set(
+ Email_Editor::class,
+ function ( $container ) {
+ return new Email_Editor(
+ $container->get( Email_Api_Controller::class ),
+ $container->get( Templates::class ),
+ $container->get( Template_Preview::class ),
+ $container->get( Patterns::class ),
+ $container->get( Settings_Controller::class ),
+ );
+ }
+ );
- $this->diContainer = $container;
- }
+ $this->diContainer = $container;
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Container_Test.php b/packages/php/email-editor/tests/unit/Container_Test.php
index 80fb3e304a..4f5a212508 100644
--- a/packages/php/email-editor/tests/unit/Container_Test.php
+++ b/packages/php/email-editor/tests/unit/Container_Test.php
@@ -7,41 +7,47 @@ use PHPUnit\Framework\TestCase;
use stdClass;
class Container_Test extends TestCase {
- public function testSetAndGetService(): void {
- $container = new Container();
+ public function testSetAndGetService(): void {
+ $container = new Container();
- $container->set('simple_service', function () {
- return new stdClass();
- });
+ $container->set(
+ 'simple_service',
+ function () {
+ return new stdClass();
+ }
+ );
- $service = $container->get('simple_service');
+ $service = $container->get( 'simple_service' );
- $this->assertInstanceOf(stdClass::class, $service);
- }
+ $this->assertInstanceOf( stdClass::class, $service );
+ }
- public function testGetReturnsSameInstance(): void {
- $container = new Container();
+ public function testGetReturnsSameInstance(): void {
+ $container = new Container();
- $container->set('singleton_service', function () {
- return new stdClass();
- });
+ $container->set(
+ 'singleton_service',
+ function () {
+ return new stdClass();
+ }
+ );
- // Retrieve the service twice
- $service1 = $container->get('singleton_service');
- $service2 = $container->get('singleton_service');
+ // Retrieve the service twice
+ $service1 = $container->get( 'singleton_service' );
+ $service2 = $container->get( 'singleton_service' );
- // Check that both instances are the same
- $this->assertSame($service1, $service2);
- }
+ // Check that both instances are the same
+ $this->assertSame( $service1, $service2 );
+ }
- public function testExceptionForNonExistingService(): void {
- // Create the container instance
- $container = new Container();
+ public function testExceptionForNonExistingService(): void {
+ // Create the container instance
+ $container = new Container();
- // Attempt to get a non-existing service should throw an exception
- $this->expectException(Exception::class);
- $this->expectExceptionMessage('Service not found: non_existing_service');
+ // Attempt to get a non-existing service should throw an exception
+ $this->expectException( Exception::class );
+ $this->expectExceptionMessage( 'Service not found: non_existing_service' );
- $container->get('non_existing_service');
- }
+ $container->get( 'non_existing_service' );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Highlighting_Postprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Highlighting_Postprocessor_Test.php
index 52df145a72..7e2c2ee28f 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Highlighting_Postprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Highlighting_Postprocessor_Test.php
@@ -5,25 +5,28 @@ namespace MailPoet\EmailEditor\Engine\Renderer\Postprocessors;
use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Postprocessors\Highlighting_Postprocessor;
class Highlighting_Postprocessor_Test extends \MailPoetUnitTest {
- /** @var Highlighting_Postprocessor */
- private $postprocessor;
+ /** @var Highlighting_Postprocessor */
+ private $postprocessor;
- public function _before() {
- parent::_before();
- $this->postprocessor = new Highlighting_Postprocessor();
- }
+ public function _before() {
+ parent::_before();
+ $this->postprocessor = new Highlighting_Postprocessor();
+ }
- public function testItReplacesHtmlElements(): void {
- $html = '
+ public function testItReplacesHtmlElements(): void {
+ $html = '
Some text
Some paragraph
Some link
';
- $result = $this->postprocessor->postprocess($html);
- $this->assertEquals( '
+ $result = $this->postprocessor->postprocess( $html );
+ $this->assertEquals(
+ '
Some text
Some paragraph
Some link
- ', $result);
- }
+ ',
+ $result
+ );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Variables_Postprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Variables_Postprocessor_Test.php
index c53486158c..27a7ea83a2 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Variables_Postprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Postprocessors/Variables_Postprocessor_Test.php
@@ -7,26 +7,26 @@ use MailPoet\EmailEditor\Engine\Theme_Controller;
use PHPUnit\Framework\MockObject\MockObject;
class Variables_Postprocessor_Test extends \MailPoetUnitTest {
- private Variables_Postprocessor $postprocessor;
+ private Variables_Postprocessor $postprocessor;
- /** @var Theme_Controller & MockObject */
- private $themeControllerMock;
+ /** @var Theme_Controller & MockObject */
+ private $themeControllerMock;
- public function _before() {
- parent::_before();
- $this->themeControllerMock = $this->createMock(Theme_Controller::class);
- $this->postprocessor = new Variables_Postprocessor($this->themeControllerMock);
- }
+ public function _before() {
+ parent::_before();
+ $this->themeControllerMock = $this->createMock( Theme_Controller::class );
+ $this->postprocessor = new Variables_Postprocessor( $this->themeControllerMock );
+ }
- public function testItReplacesVariablesInStyleAttributes(): void {
- $variablesMap = [
- '--wp--preset--spacing--10' => '10px',
- '--wp--preset--spacing--20' => '20px',
- '--wp--preset--spacing--30' => '30px',
- ];
- $this->themeControllerMock->method('get_variables_values_map')->willReturn($variablesMap);
- $html = 'Helloo I have padding var(--wp--preset--spacing--10); ';
- $result = $this->postprocessor->postprocess($html);
- $this->assertEquals('Helloo I have padding var(--wp--preset--spacing--10); ', $result);
- }
+ public function testItReplacesVariablesInStyleAttributes(): void {
+ $variablesMap = array(
+ '--wp--preset--spacing--10' => '10px',
+ '--wp--preset--spacing--20' => '20px',
+ '--wp--preset--spacing--30' => '30px',
+ );
+ $this->themeControllerMock->method( 'get_variables_values_map' )->willReturn( $variablesMap );
+ $html = 'Helloo I have padding var(--wp--preset--spacing--10); ';
+ $result = $this->postprocessor->postprocess( $html );
+ $this->assertEquals( 'Helloo I have padding var(--wp--preset--spacing--10); ', $result );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Blocks_Width_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
index 3529654360..04c990a4c1 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Blocks_Width_Preprocessor_Test.php
@@ -6,458 +6,489 @@ use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Blocks_Wi
class Blocks_Width_Preprocessor_Test extends \MailPoetUnitTest {
- /** @var Blocks_Width_Preprocessor */
- private $preprocessor;
+ /** @var Blocks_Width_Preprocessor */
+ private $preprocessor;
- /** @var array{contentSize: string} */
- private array $layout;
+ /** @var array{contentSize: string} */
+ private array $layout;
- /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
- private array $styles;
+ /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
+ private array $styles;
- public function _before() {
- parent::_before();
- $this->preprocessor = new Blocks_Width_Preprocessor();
- $this->layout = ['contentSize' => '660px'];
- $this->styles = ['spacing' => ['padding' => ['left' => '10px', 'right' => '10px', 'top' => '10px', 'bottom' => '10px'], 'blockGap' => '10px']];
- }
+ public function _before() {
+ parent::_before();
+ $this->preprocessor = new Blocks_Width_Preprocessor();
+ $this->layout = array( 'contentSize' => '660px' );
+ $this->styles = array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ 'top' => '10px',
+ 'bottom' => '10px',
+ ),
+ 'blockGap' => '10px',
+ ),
+ );
+ }
- public function testItCalculatesWidthWithoutPadding(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '50%',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '25%',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '100px',
- ],
- 'innerBlocks' => [],
- ],
- ],
- ]];
- $styles = $this->styles;
- $styles['spacing']['padding'] = ['left' => '0px', 'right' => '0px', 'top' => '0px', 'bottom' => '0px'];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $styles);
- $result = $result[0];
- $this->assertEquals('660px', $result['email_attrs']['width']);
- $this->assertCount(3, $result['innerBlocks']);
- $this->assertEquals('330px', $result['innerBlocks'][0]['email_attrs']['width']); // 660 * 0.5
- $this->assertEquals('165px', $result['innerBlocks'][1]['email_attrs']['width']); // 660 * 0.25
- $this->assertEquals('100px', $result['innerBlocks'][2]['email_attrs']['width']);
- }
+ public function testItCalculatesWidthWithoutPadding(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '50%',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '25%',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '100px',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
+ $styles = $this->styles;
+ $styles['spacing']['padding'] = array(
+ 'left' => '0px',
+ 'right' => '0px',
+ 'top' => '0px',
+ 'bottom' => '0px',
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $styles );
+ $result = $result[0];
+ $this->assertEquals( '660px', $result['email_attrs']['width'] );
+ $this->assertCount( 3, $result['innerBlocks'] );
+ $this->assertEquals( '330px', $result['innerBlocks'][0]['email_attrs']['width'] ); // 660 * 0.5
+ $this->assertEquals( '165px', $result['innerBlocks'][1]['email_attrs']['width'] ); // 660 * 0.25
+ $this->assertEquals( '100px', $result['innerBlocks'][2]['email_attrs']['width'] );
+ }
- public function testItCalculatesWidthWithLayoutPadding(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '33%',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '100px',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '20%',
- ],
- 'innerBlocks' => [],
- ],
- ],
- ]];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $result = $result[0];
- $this->assertCount(3, $result['innerBlocks']);
- $this->assertEquals('211px', $result['innerBlocks'][0]['email_attrs']['width']); // (660 - 10 - 10) * 0.33
- $this->assertEquals('100px', $result['innerBlocks'][1]['email_attrs']['width']);
- $this->assertEquals('128px', $result['innerBlocks'][2]['email_attrs']['width']); // (660 - 10 - 10) * 0.2
- }
+ public function testItCalculatesWidthWithLayoutPadding(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '33%',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '100px',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '20%',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $result = $result[0];
+ $this->assertCount( 3, $result['innerBlocks'] );
+ $this->assertEquals( '211px', $result['innerBlocks'][0]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.33
+ $this->assertEquals( '100px', $result['innerBlocks'][1]['email_attrs']['width'] );
+ $this->assertEquals( '128px', $result['innerBlocks'][2]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.2
+ }
- public function testItCalculatesWidthOfBlockInColumn(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '40%',
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '10px',
- 'right' => '10px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '60%',
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $innerBlocks = $result[0]['innerBlocks'];
+ public function testItCalculatesWidthOfBlockInColumn(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '40%',
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '60%',
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $innerBlocks = $result[0]['innerBlocks'];
- $this->assertCount(2, $innerBlocks);
- $this->assertEquals('256px', $innerBlocks[0]['email_attrs']['width']); // (660 - 10 - 10) * 0.4
- $this->assertEquals('236px', $innerBlocks[0]['innerBlocks'][0]['email_attrs']['width']); // 256 - 10 - 10
- $this->assertEquals('384px', $innerBlocks[1]['email_attrs']['width']); // (660 - 10 - 10) * 0.6
- $this->assertEquals('344px', $innerBlocks[1]['innerBlocks'][0]['email_attrs']['width']); // 384 - 25 - 15
- }
+ $this->assertCount( 2, $innerBlocks );
+ $this->assertEquals( '256px', $innerBlocks[0]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.4
+ $this->assertEquals( '236px', $innerBlocks[0]['innerBlocks'][0]['email_attrs']['width'] ); // 256 - 10 - 10
+ $this->assertEquals( '384px', $innerBlocks[1]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.6
+ $this->assertEquals( '344px', $innerBlocks[1]['innerBlocks'][0]['email_attrs']['width'] ); // 384 - 25 - 15
+ }
- public function testItAddsMissingColumnWidth(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
- $result = $this->preprocessor->preprocess($blocks, ['contentSize' => '620px'], $this->styles);
- $innerBlocks = $result[0]['innerBlocks'];
+ public function testItAddsMissingColumnWidth(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, array( 'contentSize' => '620px' ), $this->styles );
+ $innerBlocks = $result[0]['innerBlocks'];
- $this->assertCount(3, $innerBlocks);
- $this->assertEquals('200px', $innerBlocks[0]['email_attrs']['width']); // (660 - 10 - 10) * 0.33
- $this->assertEquals('200px', $innerBlocks[0]['innerBlocks'][0]['email_attrs']['width']);
- $this->assertEquals('200px', $innerBlocks[1]['email_attrs']['width']); // (660 - 10 - 10) * 0.33
- $this->assertEquals('200px', $innerBlocks[1]['innerBlocks'][0]['email_attrs']['width']);
- $this->assertEquals('200px', $innerBlocks[2]['email_attrs']['width']); // (660 - 10 - 10) * 0.33
- $this->assertEquals('200px', $innerBlocks[2]['innerBlocks'][0]['email_attrs']['width']);
- }
+ $this->assertCount( 3, $innerBlocks );
+ $this->assertEquals( '200px', $innerBlocks[0]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.33
+ $this->assertEquals( '200px', $innerBlocks[0]['innerBlocks'][0]['email_attrs']['width'] );
+ $this->assertEquals( '200px', $innerBlocks[1]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.33
+ $this->assertEquals( '200px', $innerBlocks[1]['innerBlocks'][0]['email_attrs']['width'] );
+ $this->assertEquals( '200px', $innerBlocks[2]['email_attrs']['width'] ); // (660 - 10 - 10) * 0.33
+ $this->assertEquals( '200px', $innerBlocks[2]['innerBlocks'][0]['email_attrs']['width'] );
+ }
- public function testItCalculatesMissingColumnWidth(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '33.33%',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '200px',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ]];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $innerBlocks = $result[0]['innerBlocks'];
+ public function testItCalculatesMissingColumnWidth(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '33.33%',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '200px',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $innerBlocks = $result[0]['innerBlocks'];
- $this->assertCount(3, $innerBlocks);
- $this->assertEquals('200px', $innerBlocks[0]['email_attrs']['width']); // (620 - 10 - 10) * 0.3333
- $this->assertEquals('200px', $innerBlocks[1]['email_attrs']['width']); // already defined
- $this->assertEquals('200px', $innerBlocks[2]['email_attrs']['width']); // 600 -200 - 200
- }
+ $this->assertCount( 3, $innerBlocks );
+ $this->assertEquals( '200px', $innerBlocks[0]['email_attrs']['width'] ); // (620 - 10 - 10) * 0.3333
+ $this->assertEquals( '200px', $innerBlocks[1]['email_attrs']['width'] ); // already defined
+ $this->assertEquals( '200px', $innerBlocks[2]['email_attrs']['width'] ); // 600 -200 - 200
+ }
- public function testItDoesNotSubtractPaddingForFullWidthBlocks(): void {
- $blocks = [
- [
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'align' => 'full',
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
+ public function testItDoesNotSubtractPaddingForFullWidthBlocks(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'align' => 'full',
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
- $this->assertCount(2, $result);
- $this->assertEquals('660px', $result[0]['email_attrs']['width']); // full width
- $this->assertEquals('640px', $result[1]['email_attrs']['width']); // 660 - 10 - 10
- }
+ $this->assertCount( 2, $result );
+ $this->assertEquals( '660px', $result[0]['email_attrs']['width'] ); // full width
+ $this->assertEquals( '640px', $result[1]['email_attrs']['width'] ); // 660 - 10 - 10
+ }
- public function testItCalculatesWidthForColumnWithoutDefinition(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '140px',
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '10px',
- 'right' => '10px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '20px',
- 'right' => '20px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [],
- ],
- ],
- ]];
+ public function testItCalculatesWidthForColumnWithoutDefinition(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '140px',
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '20px',
+ 'right' => '20px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(3, $result[0]['innerBlocks']);
- $this->assertEquals('140px', $result[0]['innerBlocks'][0]['email_attrs']['width']);
- $this->assertEquals('220px', $result[0]['innerBlocks'][1]['email_attrs']['width']);
- $this->assertEquals('240px', $result[0]['innerBlocks'][2]['email_attrs']['width']);
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 3, $result[0]['innerBlocks'] );
+ $this->assertEquals( '140px', $result[0]['innerBlocks'][0]['email_attrs']['width'] );
+ $this->assertEquals( '220px', $result[0]['innerBlocks'][1]['email_attrs']['width'] );
+ $this->assertEquals( '240px', $result[0]['innerBlocks'][2]['email_attrs']['width'] );
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '140px',
- 'style' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ]];
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '140px',
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(2, $result[0]['innerBlocks']);
- $this->assertEquals('140px', $result[0]['innerBlocks'][0]['email_attrs']['width']);
- $this->assertEquals('500px', $result[0]['innerBlocks'][1]['email_attrs']['width']);
- }
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 2, $result[0]['innerBlocks'] );
+ $this->assertEquals( '140px', $result[0]['innerBlocks'][0]['email_attrs']['width'] );
+ $this->assertEquals( '500px', $result[0]['innerBlocks'][1]['email_attrs']['width'] );
+ }
- public function testItCalculatesWidthForColumnWithBorder(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'style' => [
- 'border' => [
- 'width' => '10px',
- ],
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'width' => '140px',
- 'style' => [
- 'border' => [
- 'left' => [
- 'width' => '5px',
- ],
- 'right' => [
- 'width' => '5px',
- ],
- ],
- 'spacing' => [
- 'padding' => [
- 'left' => '25px',
- 'right' => '15px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/image',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'style' => [
- 'border' => [
- 'width' => '15px',
- ],
- 'spacing' => [
- 'padding' => [
- 'left' => '20px',
- 'right' => '20px',
- ],
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/image',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
+ public function testItCalculatesWidthForColumnWithBorder(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'style' => array(
+ 'border' => array(
+ 'width' => '10px',
+ ),
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'width' => '140px',
+ 'style' => array(
+ 'border' => array(
+ 'left' => array(
+ 'width' => '5px',
+ ),
+ 'right' => array(
+ 'width' => '5px',
+ ),
+ ),
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '25px',
+ 'right' => '15px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/image',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'style' => array(
+ 'border' => array(
+ 'width' => '15px',
+ ),
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '20px',
+ 'right' => '20px',
+ ),
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/image',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(3, $result[0]['innerBlocks']);
- $this->assertEquals('140px', $result[0]['innerBlocks'][0]['email_attrs']['width']);
- $this->assertEquals('185px', $result[0]['innerBlocks'][1]['email_attrs']['width']);
- $this->assertEquals('255px', $result[0]['innerBlocks'][2]['email_attrs']['width']);
- $imageBlock = $result[0]['innerBlocks'][1]['innerBlocks'][0];
- $this->assertEquals('185px', $imageBlock['email_attrs']['width']);
- $imageBlock = $result[0]['innerBlocks'][2]['innerBlocks'][0];
- $this->assertEquals('215px', $imageBlock['email_attrs']['width']);
- }
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 3, $result[0]['innerBlocks'] );
+ $this->assertEquals( '140px', $result[0]['innerBlocks'][0]['email_attrs']['width'] );
+ $this->assertEquals( '185px', $result[0]['innerBlocks'][1]['email_attrs']['width'] );
+ $this->assertEquals( '255px', $result[0]['innerBlocks'][2]['email_attrs']['width'] );
+ $imageBlock = $result[0]['innerBlocks'][1]['innerBlocks'][0];
+ $this->assertEquals( '185px', $imageBlock['email_attrs']['width'] );
+ $imageBlock = $result[0]['innerBlocks'][2]['innerBlocks'][0];
+ $this->assertEquals( '215px', $imageBlock['email_attrs']['width'] );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Cleanup_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Cleanup_Preprocessor_Test.php
index 992ffb86fd..9211302910 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Cleanup_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Cleanup_Preprocessor_Test.php
@@ -6,60 +6,76 @@ use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Cleanup_P
class Cleanup_Preprocessor_Test extends \MailPoetUnitTest {
- private const PARAGRAPH_BLOCK = [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerHTML' => 'Paragraph content',
- ];
+ private const PARAGRAPH_BLOCK = array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerHTML' => 'Paragraph content',
+ );
- private const COLUMNS_BLOCK = [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [[
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [],
- ]],
- ];
+ private const COLUMNS_BLOCK = array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ );
- /** @var Cleanup_Preprocessor */
- private $preprocessor;
+ /** @var Cleanup_Preprocessor */
+ private $preprocessor;
- /** @var array{contentSize: string} */
- private array $layout;
+ /** @var array{contentSize: string} */
+ private array $layout;
- /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
- private array $styles;
+ /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
+ private array $styles;
- public function _before() {
- parent::_before();
- $this->preprocessor = new Cleanup_Preprocessor();
- $this->layout = ['contentSize' => '660px'];
- $this->styles = ['spacing' => ['padding' => ['left' => '10px', 'right' => '10px', 'top' => '10px', 'bottom' => '10px'], 'blockGap' => '10px']];
- }
+ public function _before() {
+ parent::_before();
+ $this->preprocessor = new Cleanup_Preprocessor();
+ $this->layout = array( 'contentSize' => '660px' );
+ $this->styles = array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ 'top' => '10px',
+ 'bottom' => '10px',
+ ),
+ 'blockGap' => '10px',
+ ),
+ );
+ }
- public function testItRemovesUnwantedBlocks(): void {
- $blocks = [
- self::COLUMNS_BLOCK,
- ['blockName' => null, 'attrs' => [], 'innerHTML' => "\r\n"],
- self::PARAGRAPH_BLOCK,
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(2, $result);
- $this->assertEquals(self::COLUMNS_BLOCK, $result[0]);
- $this->assertEquals(self::PARAGRAPH_BLOCK, $result[1]);
- }
+ public function testItRemovesUnwantedBlocks(): void {
+ $blocks = array(
+ self::COLUMNS_BLOCK,
+ array(
+ 'blockName' => null,
+ 'attrs' => array(),
+ 'innerHTML' => "\r\n",
+ ),
+ self::PARAGRAPH_BLOCK,
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 2, $result );
+ $this->assertEquals( self::COLUMNS_BLOCK, $result[0] );
+ $this->assertEquals( self::PARAGRAPH_BLOCK, $result[1] );
+ }
- public function testItPreservesAllRelevantBlocks(): void {
- $blocks = [
- self::COLUMNS_BLOCK,
- self::PARAGRAPH_BLOCK,
- self::COLUMNS_BLOCK,
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(3, $result);
- $this->assertEquals(self::COLUMNS_BLOCK, $result[0]);
- $this->assertEquals(self::PARAGRAPH_BLOCK, $result[1]);
- $this->assertEquals(self::COLUMNS_BLOCK, $result[2]);
- }
+ public function testItPreservesAllRelevantBlocks(): void {
+ $blocks = array(
+ self::COLUMNS_BLOCK,
+ self::PARAGRAPH_BLOCK,
+ self::COLUMNS_BLOCK,
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 3, $result );
+ $this->assertEquals( self::COLUMNS_BLOCK, $result[0] );
+ $this->assertEquals( self::PARAGRAPH_BLOCK, $result[1] );
+ $this->assertEquals( self::COLUMNS_BLOCK, $result[2] );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Spacing_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Spacing_Preprocessor_Test.php
index c99c8dffbd..52fb104150 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Spacing_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Spacing_Preprocessor_Test.php
@@ -6,73 +6,83 @@ use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Spacing_P
class Spacing_Preprocessor_Test extends \MailPoetUnitTest {
- /** @var Spacing_Preprocessor */
- private $preprocessor;
+ /** @var Spacing_Preprocessor */
+ private $preprocessor;
- /** @var array{contentSize: string} */
- private array $layout;
+ /** @var array{contentSize: string} */
+ private array $layout;
- /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
- private array $styles;
+ /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
+ private array $styles;
- public function _before() {
- parent::_before();
- $this->preprocessor = new Spacing_Preprocessor();
- $this->layout = ['contentSize' => '660px'];
- $this->styles = ['spacing' => ['padding' => ['left' => '10px', 'right' => '10px', 'top' => '10px', 'bottom' => '10px'], 'blockGap' => '10px']];
- }
+ public function _before() {
+ parent::_before();
+ $this->preprocessor = new Spacing_Preprocessor();
+ $this->layout = array( 'contentSize' => '660px' );
+ $this->styles = array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ 'top' => '10px',
+ 'bottom' => '10px',
+ ),
+ 'blockGap' => '10px',
+ ),
+ );
+ }
- public function testItAddsDefaultVerticalSpacing(): void {
- $blocks = [
- [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/list',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/img',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ],
- [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ];
+ public function testItAddsDefaultVerticalSpacing(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/list',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/img',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ );
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $this->assertCount(2, $result);
- $firstColumns = $result[0];
- $secondColumns = $result[1];
- $nestedColumn = $firstColumns['innerBlocks'][0];
- $nestedColumnFirstItem = $nestedColumn['innerBlocks'][0];
- $nestedColumnSecondItem = $nestedColumn['innerBlocks'][1];
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $this->assertCount( 2, $result );
+ $firstColumns = $result[0];
+ $secondColumns = $result[1];
+ $nestedColumn = $firstColumns['innerBlocks'][0];
+ $nestedColumnFirstItem = $nestedColumn['innerBlocks'][0];
+ $nestedColumnSecondItem = $nestedColumn['innerBlocks'][1];
- // First elements should not have margin-top, but others should.
- $this->assertArrayNotHasKey('margin-top', $firstColumns['email_attrs']);
- $this->assertArrayNotHasKey('margin-top', $secondColumns['email_attrs']);
- $this->assertArrayNotHasKey('margin-top', $nestedColumn['email_attrs']);
- $this->assertArrayNotHasKey('margin-top', $nestedColumnFirstItem['email_attrs']);
- $this->assertArrayHasKey('margin-top', $nestedColumnSecondItem['email_attrs']);
- $this->assertEquals('10px', $nestedColumnSecondItem['email_attrs']['margin-top']);
- }
+ // First elements should not have margin-top, but others should.
+ $this->assertArrayNotHasKey( 'margin-top', $firstColumns['email_attrs'] );
+ $this->assertArrayNotHasKey( 'margin-top', $secondColumns['email_attrs'] );
+ $this->assertArrayNotHasKey( 'margin-top', $nestedColumn['email_attrs'] );
+ $this->assertArrayNotHasKey( 'margin-top', $nestedColumnFirstItem['email_attrs'] );
+ $this->assertArrayHasKey( 'margin-top', $nestedColumnSecondItem['email_attrs'] );
+ $this->assertEquals( '10px', $nestedColumnSecondItem['email_attrs']['margin-top'] );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Typography_Preprocessor_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Typography_Preprocessor_Test.php
index 4417ff2fd5..fe01adfd16 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Typography_Preprocessor_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Preprocessors/Typography_Preprocessor_Test.php
@@ -7,270 +7,306 @@ use MailPoet\EmailEditor\Engine\Settings_Controller;
class Typography_Preprocessor_Test extends \MailPoetUnitTest {
- /** @var Typography_Preprocessor */
- private $preprocessor;
+ /** @var Typography_Preprocessor */
+ private $preprocessor;
- /** @var array{contentSize: string} */
- private array $layout;
+ /** @var array{contentSize: string} */
+ private array $layout;
- /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
- private array $styles;
+ /** @var array{spacing: array{padding: array{bottom: string, left: string, right: string, top: string}, blockGap: string}} $styles */
+ private array $styles;
- public function _before() {
- parent::_before();
- $settingsMock = $this->createMock(Settings_Controller::class);
- $themeMock = $this->createMock(\WP_Theme_JSON::class);
- $themeMock->method('get_data')->willReturn([
- 'styles' => [
- 'color' => [
- 'text' => '#000000',
- ],
- 'typography' => [
- 'fontSize' => '13px',
- 'fontFamily' => 'Arial',
- ],
- ],
- 'settings' => [
- 'typography' => [
- 'fontFamilies' => [
- [
- 'slug' => 'arial-slug',
- 'name' => 'Arial Name',
- 'fontFamily' => 'Arial',
- ],
- [
- 'slug' => 'georgia-slug',
- 'name' => 'Georgia Name',
- 'fontFamily' => 'Georgia',
- ],
- ],
- ],
- ],
- ]);
- $settingsMock->method('get_theme')->willReturn($themeMock);
- // This slug translate mock expect slugs in format slug-10px and will return 10px
- $settingsMock->method('translate_slug_to_font_size')->willReturnCallback(function($slug) {
- return str_replace('slug-', '', $slug);
- });
- $this->preprocessor = new Typography_Preprocessor($settingsMock);
- $this->layout = ['contentSize' => '660px'];
- $this->styles = ['spacing' => ['padding' => ['left' => '10px', 'right' => '10px', 'top' => '10px', 'bottom' => '10px'], 'blockGap' => '10px']];
- }
+ public function _before() {
+ parent::_before();
+ $settingsMock = $this->createMock( Settings_Controller::class );
+ $themeMock = $this->createMock( \WP_Theme_JSON::class );
+ $themeMock->method( 'get_data' )->willReturn(
+ array(
+ 'styles' => array(
+ 'color' => array(
+ 'text' => '#000000',
+ ),
+ 'typography' => array(
+ 'fontSize' => '13px',
+ 'fontFamily' => 'Arial',
+ ),
+ ),
+ 'settings' => array(
+ 'typography' => array(
+ 'fontFamilies' => array(
+ array(
+ 'slug' => 'arial-slug',
+ 'name' => 'Arial Name',
+ 'fontFamily' => 'Arial',
+ ),
+ array(
+ 'slug' => 'georgia-slug',
+ 'name' => 'Georgia Name',
+ 'fontFamily' => 'Georgia',
+ ),
+ ),
+ ),
+ ),
+ )
+ );
+ $settingsMock->method( 'get_theme' )->willReturn( $themeMock );
+ // This slug translate mock expect slugs in format slug-10px and will return 10px
+ $settingsMock->method( 'translate_slug_to_font_size' )->willReturnCallback(
+ function ( $slug ) {
+ return str_replace( 'slug-', '', $slug );
+ }
+ );
+ $this->preprocessor = new Typography_Preprocessor( $settingsMock );
+ $this->layout = array( 'contentSize' => '660px' );
+ $this->styles = array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ 'top' => '10px',
+ 'bottom' => '10px',
+ ),
+ 'blockGap' => '10px',
+ ),
+ );
+ }
- public function testItCopiesColumnsTypography(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'fontFamily' => 'arial-slug',
- 'style' => [
- 'color' => [
- 'text' => '#aa00dd',
- ],
- 'typography' => [
- 'fontSize' => '12px',
- 'textDecoration' => 'underline',
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
- $expectedEmailAttrs = [
- 'color' => '#aa00dd',
- 'font-size' => '12px',
- 'text-decoration' => 'underline',
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $result = $result[0];
- $this->assertCount(2, $result['innerBlocks']);
- $this->assertEquals($expectedEmailAttrs, $result['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][1]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs']);
- }
+ public function testItCopiesColumnsTypography(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'fontFamily' => 'arial-slug',
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#aa00dd',
+ ),
+ 'typography' => array(
+ 'fontSize' => '12px',
+ 'textDecoration' => 'underline',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $expectedEmailAttrs = array(
+ 'color' => '#aa00dd',
+ 'font-size' => '12px',
+ 'text-decoration' => 'underline',
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $result = $result[0];
+ $this->assertCount( 2, $result['innerBlocks'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][1]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'] );
+ }
- public function testItReplacesFontSizeSlugsWithValues(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'fontSize' => 'slug-20px',
- 'style' => [],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
- $expectedEmailAttrs = [
- 'color' => '#000000',
- 'font-size' => '20px',
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $result = $result[0];
- $this->assertCount(2, $result['innerBlocks']);
- $this->assertEquals($expectedEmailAttrs, $result['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][1]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs']);
- }
+ public function testItReplacesFontSizeSlugsWithValues(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'fontSize' => 'slug-20px',
+ 'style' => array(),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $expectedEmailAttrs = array(
+ 'color' => '#000000',
+ 'font-size' => '20px',
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $result = $result[0];
+ $this->assertCount( 2, $result['innerBlocks'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][1]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'] );
+ }
- public function testItDoesNotCopyColumnsWidth(): void {
- $blocks = [[
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'email_attrs' => [
- 'width' => '640px',
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [],
- ],
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ]];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $result = $result[0];
- $this->assertCount(2, $result['innerBlocks']);
- $this->assertEquals(['width' => '640px', 'color' => '#000000', 'font-size' => '13px'], $result['email_attrs']);
- $defaultFontStyles = ['color' => '#000000', 'font-size' => '13px'];
- $this->assertEquals($defaultFontStyles, $result['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($defaultFontStyles, $result['innerBlocks'][1]['email_attrs']);
- $this->assertEquals($defaultFontStyles, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs']);
- }
+ public function testItDoesNotCopyColumnsWidth(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'email_attrs' => array(
+ 'width' => '640px',
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $result = $result[0];
+ $this->assertCount( 2, $result['innerBlocks'] );
+ $this->assertEquals(
+ array(
+ 'width' => '640px',
+ 'color' => '#000000',
+ 'font-size' => '13px',
+ ),
+ $result['email_attrs']
+ );
+ $defaultFontStyles = array(
+ 'color' => '#000000',
+ 'font-size' => '13px',
+ );
+ $this->assertEquals( $defaultFontStyles, $result['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $defaultFontStyles, $result['innerBlocks'][1]['email_attrs'] );
+ $this->assertEquals( $defaultFontStyles, $result['innerBlocks'][1]['innerBlocks'][0]['email_attrs'] );
+ }
- public function testItOverridesColumnsTypography(): void {
- $blocks = [
- [
- 'blockName' => 'core/columns',
- 'attrs' => [
- 'fontFamily' => 'arial-slug',
- 'style' => [
- 'color' => [
- 'text' => '#aa00dd',
- ],
- 'typography' => [
- 'fontSize' => '12px',
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'fontFamily' => 'georgia-slug',
- 'style' => [
- 'color' => [
- 'text' => '#cc22aa',
- ],
- 'typography' => [
- 'fontSize' => '18px',
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- [
- 'blockName' => 'core/column',
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ],
- [
- 'blockName' => 'core/columns',
- 'attrs' => [],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/column',
- 'attrs' => [
- 'fontFamily' => 'georgia-slug',
- 'style' => [
- 'color' => [
- 'text' => '#cc22aa',
- ],
- 'typography' => [
- 'fontSize' => '18px',
- ],
- ],
- ],
- 'innerBlocks' => [
- [
- 'blockName' => 'core/paragraph',
- 'attrs' => [],
- 'innerBlocks' => [],
- ],
- ],
- ],
- ],
- ],
- ];
- $expectedEmailAttrs1 = [
- 'color' => '#aa00dd',
- 'font-size' => '12px',
- ];
- $expectedEmailAttrs2 = [
- 'color' => '#cc22aa',
- 'font-size' => '18px',
- ];
- $result = $this->preprocessor->preprocess($blocks, $this->layout, $this->styles);
- $child1 = $result[0];
- $child2 = $result[1];
- $this->assertCount(2, $child1['innerBlocks']);
- $this->assertEquals($expectedEmailAttrs1, $child1['email_attrs']);
- $this->assertEquals($expectedEmailAttrs2, $child1['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs2, $child1['innerBlocks'][0]['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs1, $child1['innerBlocks'][1]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs1, $child1['innerBlocks'][1]['innerBlocks'][0]['email_attrs']);
- $this->assertCount(1, $child2['innerBlocks']);
- $this->assertEquals(['color' => '#000000', 'font-size' => '13px'], $child2['email_attrs']);
- $this->assertEquals($expectedEmailAttrs2, $child2['innerBlocks'][0]['email_attrs']);
- $this->assertEquals($expectedEmailAttrs2, $child2['innerBlocks'][0]['innerBlocks'][0]['email_attrs']);
- }
+ public function testItOverridesColumnsTypography(): void {
+ $blocks = array(
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(
+ 'fontFamily' => 'arial-slug',
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#aa00dd',
+ ),
+ 'typography' => array(
+ 'fontSize' => '12px',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'fontFamily' => 'georgia-slug',
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#cc22aa',
+ ),
+ 'typography' => array(
+ 'fontSize' => '18px',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/column',
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'blockName' => 'core/columns',
+ 'attrs' => array(),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/column',
+ 'attrs' => array(
+ 'fontFamily' => 'georgia-slug',
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#cc22aa',
+ ),
+ 'typography' => array(
+ 'fontSize' => '18px',
+ ),
+ ),
+ ),
+ 'innerBlocks' => array(
+ array(
+ 'blockName' => 'core/paragraph',
+ 'attrs' => array(),
+ 'innerBlocks' => array(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ $expectedEmailAttrs1 = array(
+ 'color' => '#aa00dd',
+ 'font-size' => '12px',
+ );
+ $expectedEmailAttrs2 = array(
+ 'color' => '#cc22aa',
+ 'font-size' => '18px',
+ );
+ $result = $this->preprocessor->preprocess( $blocks, $this->layout, $this->styles );
+ $child1 = $result[0];
+ $child2 = $result[1];
+ $this->assertCount( 2, $child1['innerBlocks'] );
+ $this->assertEquals( $expectedEmailAttrs1, $child1['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs2, $child1['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs2, $child1['innerBlocks'][0]['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs1, $child1['innerBlocks'][1]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs1, $child1['innerBlocks'][1]['innerBlocks'][0]['email_attrs'] );
+ $this->assertCount( 1, $child2['innerBlocks'] );
+ $this->assertEquals(
+ array(
+ 'color' => '#000000',
+ 'font-size' => '13px',
+ ),
+ $child2['email_attrs']
+ );
+ $this->assertEquals( $expectedEmailAttrs2, $child2['innerBlocks'][0]['email_attrs'] );
+ $this->assertEquals( $expectedEmailAttrs2, $child2['innerBlocks'][0]['innerBlocks'][0]['email_attrs'] );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Renderer/Process_Manager_Test.php b/packages/php/email-editor/tests/unit/Engine/Renderer/Process_Manager_Test.php
index 264f010a78..3eee9b5c28 100644
--- a/packages/php/email-editor/tests/unit/Engine/Renderer/Process_Manager_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Renderer/Process_Manager_Test.php
@@ -11,42 +11,42 @@ use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors\Typograph
use MailPoet\EmailEditor\Engine\Renderer\ContentRenderer\Process_Manager;
class Process_Manager_Test extends \MailPoetUnitTest {
- public function testItCallsPreprocessorsProperly(): void {
- $layout = [
- 'contentSize' => '600px',
- ];
- $styles = [
- 'spacing' => [
- 'blockGap' => '0px',
- 'padding' => [
- 'bottom' => '0px',
- 'left' => '0px',
- 'right' => '0px',
- 'top' => '0px',
- ],
- ],
- ];
+ public function testItCallsPreprocessorsProperly(): void {
+ $layout = array(
+ 'contentSize' => '600px',
+ );
+ $styles = array(
+ 'spacing' => array(
+ 'blockGap' => '0px',
+ 'padding' => array(
+ 'bottom' => '0px',
+ 'left' => '0px',
+ 'right' => '0px',
+ 'top' => '0px',
+ ),
+ ),
+ );
- $cleanup = $this->createMock(Cleanup_Preprocessor::class);
- $cleanup->expects($this->once())->method('preprocess')->willReturn([]);
+ $cleanup = $this->createMock( Cleanup_Preprocessor::class );
+ $cleanup->expects( $this->once() )->method( 'preprocess' )->willReturn( array() );
- $blocksWidth = $this->createMock(Blocks_Width_Preprocessor::class);
- $blocksWidth->expects($this->once())->method('preprocess')->willReturn([]);
+ $blocksWidth = $this->createMock( Blocks_Width_Preprocessor::class );
+ $blocksWidth->expects( $this->once() )->method( 'preprocess' )->willReturn( array() );
- $typography = $this->createMock(Typography_Preprocessor::class);
- $typography->expects($this->once())->method('preprocess')->willReturn([]);
+ $typography = $this->createMock( Typography_Preprocessor::class );
+ $typography->expects( $this->once() )->method( 'preprocess' )->willReturn( array() );
- $spacing = $this->createMock(Spacing_Preprocessor::class);
- $spacing->expects($this->once())->method('preprocess')->willReturn([]);
+ $spacing = $this->createMock( Spacing_Preprocessor::class );
+ $spacing->expects( $this->once() )->method( 'preprocess' )->willReturn( array() );
- $highlighting = $this->createMock(Highlighting_Postprocessor::class);
- $highlighting->expects($this->once())->method('postprocess')->willReturn('');
+ $highlighting = $this->createMock( Highlighting_Postprocessor::class );
+ $highlighting->expects( $this->once() )->method( 'postprocess' )->willReturn( '' );
- $variables = $this->createMock(Variables_Postprocessor::class);
- $variables->expects($this->once())->method('postprocess')->willReturn('');
+ $variables = $this->createMock( Variables_Postprocessor::class );
+ $variables->expects( $this->once() )->method( 'postprocess' )->willReturn( '' );
- $processManager = new Process_Manager($cleanup, $blocksWidth, $typography, $spacing, $highlighting, $variables);
- $this->assertEquals([], $processManager->preprocess([], $layout, $styles));
- $this->assertEmpty($processManager->postprocess(''));
- }
+ $processManager = new Process_Manager( $cleanup, $blocksWidth, $typography, $spacing, $highlighting, $variables );
+ $this->assertEquals( array(), $processManager->preprocess( array(), $layout, $styles ) );
+ $this->assertEmpty( $processManager->postprocess( '' ) );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Engine/Settings_Controller_Test.php b/packages/php/email-editor/tests/unit/Engine/Settings_Controller_Test.php
index 8430c5e486..115a190a06 100644
--- a/packages/php/email-editor/tests/unit/Engine/Settings_Controller_Test.php
+++ b/packages/php/email-editor/tests/unit/Engine/Settings_Controller_Test.php
@@ -3,28 +3,32 @@
namespace MailPoet\EmailEditor\Engine;
class Settings_Controller_Test extends \MailPoetUnitTest {
- public function testItGetsCorrectLayoutWidthWithoutPadding(): void {
- $themeJsonMock = $this->createMock(\WP_Theme_JSON::class);
- $themeJsonMock->method('get_data')->willReturn([
- 'styles' => [
- 'spacing' => [
- 'padding' => [
- 'left' => '10px',
- 'right' => '10px',
- ],
- ],
- ],
- ]);
- $themeController = $this->createMock(Theme_Controller::class);
- $themeController->method('get_theme')->willReturn($themeJsonMock);
- $themeController->method('get_layout_settings')->willReturn([
- "contentSize" => "660px",
- "wideSize" => null,
- ]);
- $settingsController = new Settings_Controller($themeController);
- $layoutWidth = $settingsController->get_layout_width_without_padding();
- // default width is 660px and if we subtract padding from left and right we must get the correct value
- $expectedWidth = 660 - 10 * 2;
- $this->assertEquals($expectedWidth . 'px', $layoutWidth);
- }
+ public function testItGetsCorrectLayoutWidthWithoutPadding(): void {
+ $themeJsonMock = $this->createMock( \WP_Theme_JSON::class );
+ $themeJsonMock->method( 'get_data' )->willReturn(
+ array(
+ 'styles' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'left' => '10px',
+ 'right' => '10px',
+ ),
+ ),
+ ),
+ )
+ );
+ $themeController = $this->createMock( Theme_Controller::class );
+ $themeController->method( 'get_theme' )->willReturn( $themeJsonMock );
+ $themeController->method( 'get_layout_settings' )->willReturn(
+ array(
+ 'contentSize' => '660px',
+ 'wideSize' => null,
+ )
+ );
+ $settingsController = new Settings_Controller( $themeController );
+ $layoutWidth = $settingsController->get_layout_width_without_padding();
+ // default width is 660px and if we subtract padding from left and right we must get the correct value
+ $expectedWidth = 660 - 10 * 2;
+ $this->assertEquals( $expectedWidth . 'px', $layoutWidth );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/Integrations/Utils/Dom_Document_Helper_Test.php b/packages/php/email-editor/tests/unit/Integrations/Utils/Dom_Document_Helper_Test.php
index 498cbb8d16..3a765a394f 100644
--- a/packages/php/email-editor/tests/unit/Integrations/Utils/Dom_Document_Helper_Test.php
+++ b/packages/php/email-editor/tests/unit/Integrations/Utils/Dom_Document_Helper_Test.php
@@ -3,43 +3,43 @@
namespace MailPoet\EmailEditor\Integrations\Utils;
class Dom_Document_Helper_Test extends \MailPoetUnitTest {
- public function testItFindsElement(): void {
- $html = '';
- $domDocumentHelper = new Dom_Document_Helper($html);
- $element = $domDocumentHelper->find_element('p');
- $empty = $domDocumentHelper->find_element('span');
- $this->assertInstanceOf(\DOMElement::class, $element);
- $this->assertEquals('p', $element->tagName);
- $this->assertNull($empty);
- }
+ public function testItFindsElement(): void {
+ $html = '';
+ $domDocumentHelper = new Dom_Document_Helper( $html );
+ $element = $domDocumentHelper->find_element( 'p' );
+ $empty = $domDocumentHelper->find_element( 'span' );
+ $this->assertInstanceOf( \DOMElement::class, $element );
+ $this->assertEquals( 'p', $element->tagName );
+ $this->assertNull( $empty );
+ }
- public function testItGetsAttributeValue(): void {
- $html = '';
- $domDocumentHelper = new Dom_Document_Helper($html);
- $element = $domDocumentHelper->find_element('p');
- $this->assertInstanceOf(\DOMElement::class, $element);
- $this->assertEquals('some-class', $domDocumentHelper->get_attribute_value($element, 'class'));
- }
+ public function testItGetsAttributeValue(): void {
+ $html = '';
+ $domDocumentHelper = new Dom_Document_Helper( $html );
+ $element = $domDocumentHelper->find_element( 'p' );
+ $this->assertInstanceOf( \DOMElement::class, $element );
+ $this->assertEquals( 'some-class', $domDocumentHelper->get_attribute_value( $element, 'class' ) );
+ }
- public function testItGetsOuterHtml(): void {
- $html = 'Some text ';
- $domDocumentHelper = new Dom_Document_Helper($html);
- $element = $domDocumentHelper->find_element('span');
- $this->assertInstanceOf(\DOMElement::class, $element);
- $this->assertEquals('Some text', $domDocumentHelper->get_outer_html($element));
+ public function testItGetsOuterHtml(): void {
+ $html = 'Some text ';
+ $domDocumentHelper = new Dom_Document_Helper( $html );
+ $element = $domDocumentHelper->find_element( 'span' );
+ $this->assertInstanceOf( \DOMElement::class, $element );
+ $this->assertEquals( 'Some text', $domDocumentHelper->get_outer_html( $element ) );
- // testings encoding of special characters
- $html = '';
- $domDocumentHelper = new Dom_Document_Helper($html);
- $element = $domDocumentHelper->find_element('img');
- $this->assertInstanceOf(\DOMElement::class, $element);
- $this->assertEquals(' ', $domDocumentHelper->get_outer_html($element));
- }
+ // testings encoding of special characters
+ $html = '';
+ $domDocumentHelper = new Dom_Document_Helper( $html );
+ $element = $domDocumentHelper->find_element( 'img' );
+ $this->assertInstanceOf( \DOMElement::class, $element );
+ $this->assertEquals( ' ', $domDocumentHelper->get_outer_html( $element ) );
+ }
- public function testItGetsAttributeValueByTagName(): void {
- $html = '';
- $domDocumentHelper = new Dom_Document_Helper($html);
- $this->assertEquals('some-class', $domDocumentHelper->get_attribute_value_by_tag_name('p', 'class'));
- $this->assertNull($domDocumentHelper->get_attribute_value_by_tag_name('span', 'class'));
- }
+ public function testItGetsAttributeValueByTagName(): void {
+ $html = '';
+ $domDocumentHelper = new Dom_Document_Helper( $html );
+ $this->assertEquals( 'some-class', $domDocumentHelper->get_attribute_value_by_tag_name( 'p', 'class' ) );
+ $this->assertNull( $domDocumentHelper->get_attribute_value_by_tag_name( 'span', 'class' ) );
+ }
}
diff --git a/packages/php/email-editor/tests/unit/_bootstrap.php b/packages/php/email-editor/tests/unit/_bootstrap.php
index 5f76831b4a..3d470608fb 100644
--- a/packages/php/email-editor/tests/unit/_bootstrap.php
+++ b/packages/php/email-editor/tests/unit/_bootstrap.php
@@ -1,16 +1,16 @@
|