Skip to content

Commit

Permalink
OEL-3420: Added test without title and added filter for template.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiberiu Dumitru committed Oct 9, 2024
1 parent a08eba0 commit 1fcc502
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function testRendering(): void {
'second option',
$text->html()
);
// Blcokquote.
// Blockquote.
$text = $crawler->filter('blockquote p');
$this->assertCount(1, $text);
$this->assertStringContainsString(
Expand All @@ -117,4 +117,33 @@ public function testRendering(): void {
);
}

/**
* Tests the rendering when 'field_oe_title' is empty.
*/
public function testRenderingWithoutTitle(): void {
$text_original = '<p id="paragraph-1">Lorem ipsum dolor sit amet</p>';
$paragraph = Paragraph::create([
'type' => 'oe_rich_text',
'field_oe_text_long' => [
'value' => $text_original,
'format' => 'filtered_html',
],
]);
$paragraph->save();

$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$title = $crawler->filter('h2');
$this->assertCount(0, $title);

// Ensure the body content is still rendered correctly.
$text = $crawler->filter('p#paragraph-1');
$this->assertCount(1, $text);
$this->assertStringContainsString(
'Lorem ipsum dolor sit amet',
$text->html()
);
}

}
2 changes: 1 addition & 1 deletion templates/paragraphs/paragraph--oe-rich-text.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @see ./modules/contrib/paragraphs/templates/paragraph.html.twig
*/
#}
{% if content.field_oe_title is not empty %}
{% if content.field_oe_title|field_value is not empty %}
{% include '@oe-bcl/bcl-heading/heading.html.twig' with {
title: content.field_oe_title,
} only %}
Expand Down

0 comments on commit 1fcc502

Please sign in to comment.