diContainer->get(EmailEditor::class)->initialize(); $this->diContainer->get(BlockTypesController::class)->initialize(); $this->renderer = $this->diContainer->get(ContentRenderer::class); $this->emailPost = new \WP_Post((object)[ 'ID' => 1, 'post_content' => '
Hello!
', ]); } public function testItRendersContent(): void { $template = new \WP_Block_Template(); $template->id = 'template-id'; $template->content = ''; $content = $this->renderer->render( $this->emailPost, $template ); verify($content)->stringContainsString('Hello!'); } public function testItInlinesContentStyles(): void { $template = new \WP_Block_Template(); $template->id = 'template-id'; $template->content = ''; $rendered = $this->renderer->render($this->emailPost, $template); $paragraphStyles = $this->getStylesValueForTag($rendered, 'p'); verify($paragraphStyles)->stringContainsString('margin: 0'); verify($paragraphStyles)->stringContainsString('display: block'); } private function getStylesValueForTag($html, $tag): ?string { $html = new \WP_HTML_Tag_Processor($html); if ($html->next_tag($tag)) { return $html->get_attribute('style'); } return null; } }