diff --git a/src/Prismic/Dom/RichText.php b/src/Prismic/Dom/RichText.php index a7a74f45..48b90993 100644 --- a/src/Prismic/Dom/RichText.php +++ b/src/Prismic/Dom/RichText.php @@ -32,7 +32,7 @@ public static function asText($richText) } } - return $result; + return trim($result); } /** diff --git a/tests/Prismic/Dom/RichTextTest.php b/tests/Prismic/Dom/RichTextTest.php index 98f2f833..ef794925 100644 --- a/tests/Prismic/Dom/RichTextTest.php +++ b/tests/Prismic/Dom/RichTextTest.php @@ -20,9 +20,29 @@ protected function setUp(): void public function testAsText() { - $expected = "The title\n"; - $actual = RichText::asText($this->richText->title); - $this->assertEquals($expected, $actual); + $expected = ( + "Heading 1\n". + "Heading 2\n". + "Heading 3\n". + "Heading 4\n". + "Heading 5\n". + "Heading 6\n". + "Paragraph em and strong\n". + "Paragraph Web link and media link\n". + "Preformatted block\n". + "Help\n". + "Revolver\n". + "Abbey Road\n". + "John\n". + "Paul\n". + "George\n". + "Ringo" + ); + + $this->assertEquals($expected, RichText::asText($this->richText->description)); + $this->assertEquals($expected, RichText::asText($this->richText->description, $this->linkResolver)); + + $this->assertStringEndsNotWith("\n", RichText::asText($this->richText->description)); } public function testAsHtml()