Use user theme in renderer instead of template themes

We no longer read styles associate with templates when we render an email
but we read the user theme instead
[MAILPOET-6335]
This commit is contained in:
Rostislav Wolny
2024-12-10 17:04:13 +01:00
committed by Aschepikov
parent 15818f37ef
commit 1e1bec4ce0
5 changed files with 73 additions and 104 deletions

View File

@@ -65,38 +65,10 @@ class Renderer_Test extends \MailPoetTest {
$theme_controller_mock->method( 'get_styles' )->willReturn( $styles );
$theme_controller_mock->method( 'get_layout_settings' )->willReturn( array( 'contentSize' => '660px' ) );
// We need to mock only the get_block_template_theme method and templates need to be initialized.
$templates_mock = $this->getMockBuilder( Templates::class )
->setConstructorArgs( array( $this->di_container->get( Utils::class ) ) )
->onlyMethods( array( 'get_block_template_theme' ) )
->getMock();
$templates_mock->initialize();
$templates_mock->method( 'get_block_template_theme' )->willReturn(
array(
'version' => 3,
'styles' => array(
'elements' => array(
'h1' => array(
'typography' => array(
'fontFamily' => 'lato test',
),
),
'heading' => array(
'color' => array(
'background' => 'pale-pink',
),
),
),
),
)
);
$this->renderer = $this->getServiceWithOverrides(
Renderer::class,
array(
'theme_controller' => $theme_controller_mock,
'templates' => $templates_mock,
)
);
$this->email_post = $this->tester->create_post(
@@ -179,28 +151,6 @@ class Renderer_Test extends \MailPoetTest {
verify( $style )->stringContainsString( 'max-width: 660px;' );
}
/**
* Test it inlines block styles from template.
*/
public function testItRendersTemplateStyles(): void {
$email = $this->tester->create_post(
array(
'post_content' => '<!-- wp:heading {"level":1} --><h1 class="wp-block-heading">Hello!</h1><!-- /wp:heading -->',
)
);
$rendered = $this->renderer->render(
$email,
'Subject 1',
'Preheader content 2',
'en',
'noindex,nofollow'
);
verify( $rendered['html'] )->stringContainsString( 'Subject' );
verify( $rendered['html'] )->stringContainsString( 'font-family: lato test;' );
verify( $rendered['html'] )->stringContainsString( ' background-color: pale-pink;' );
}
/**
* Returns the value of the style attribute for the first tag that matches the query.
*