From c4e69b1ce55f1bda03e96d99813589937ad68276 Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 11:19:36 +0000 Subject: [PATCH 1/6] Change to see what's the issue here --- tests/src/Kernel/EntityViewBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index 088fc03..3a05f40 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -92,7 +92,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { HTML; $actual_html = $this->renderPlain($build); - self::assertSame(self::normalizeHtml($expected_html), self::normalizeHtml($actual_html)); + self::assertSame(htmlspecialchars(self::normalizeHtml($expected_html)), htmlspecialchars(self::normalizeHtml($actual_html))); // -- Teaser mode. $build = $view_builder->build($public_node, 'teaser'); From 9250ae922438163c352da617d15a758f4379a9b2 Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 12:47:12 +0000 Subject: [PATCH 2/6] Playing around with the test to find the error. --- tests/src/Kernel/EntityViewBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index 3a05f40..5965209 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -92,7 +92,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { HTML; $actual_html = $this->renderPlain($build); - self::assertSame(htmlspecialchars(self::normalizeHtml($expected_html)), htmlspecialchars(self::normalizeHtml($actual_html))); + self::assertSame((string)$expected_html)), (string)$actual_html)); // -- Teaser mode. $build = $view_builder->build($public_node, 'teaser'); From 8775a16566b631a55122749f05b47cff099c8be7 Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 12:57:43 +0000 Subject: [PATCH 3/6] Fixed typo --- tests/src/Kernel/EntityViewBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index 5965209..aa11dff 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -92,7 +92,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { HTML; $actual_html = $this->renderPlain($build); - self::assertSame((string)$expected_html)), (string)$actual_html)); + self::assertSame((string)$expected_html, (string)$actual_html); // -- Teaser mode. $build = $view_builder->build($public_node, 'teaser'); From 89d2aa7f41c2684336a4424638249ec69291b3de Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 13:11:12 +0000 Subject: [PATCH 4/6] Update EntityViewBuilderTest.php --- tests/src/Kernel/EntityViewBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index aa11dff..2c568b0 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -92,7 +92,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { HTML; $actual_html = $this->renderPlain($build); - self::assertSame((string)$expected_html, (string)$actual_html); + self::assertSame(trim((string)$expected_html), trim((string)$actual_html)); // -- Teaser mode. $build = $view_builder->build($public_node, 'teaser'); From 55ec859fc6ccc19a083f32d0eeb959bf3b6ec5d2 Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 14:00:06 +0000 Subject: [PATCH 5/6] Reset to orignal state and just use trim() instead of rtrim --- tests/src/Kernel/EntityViewBuilderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index 2c568b0..5b32783 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -92,7 +92,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { HTML; $actual_html = $this->renderPlain($build); - self::assertSame(trim((string)$expected_html), trim((string)$actual_html)); + self::assertSame(self::normalizeHtml($expected_html), self::normalizeHtml($actual_html)); // -- Teaser mode. $build = $view_builder->build($public_node, 'teaser'); @@ -196,7 +196,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { * Normalizes the provided HTML. */ private static function normalizeHtml(string $html): string { - return rtrim(preg_replace(['#\s{2,}#', '#\n#'], '', $html)); + return trim(preg_replace(['#\s{2,}#', '#\n#'], '', $html)); } } From 92d4cd4d4c7be1cebe843802ca98f512fe4a877c Mon Sep 17 00:00:00 2001 From: Julian Pustkuchen <3110-Anybody@users.noreply.drupalcode.org> Date: Wed, 10 May 2023 19:27:53 +0000 Subject: [PATCH 6/6] Align with core template changes. --- tests/src/Kernel/EntityViewBuilderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/Kernel/EntityViewBuilderTest.php b/tests/src/Kernel/EntityViewBuilderTest.php index 5b32783..5f3c665 100644 --- a/tests/src/Kernel/EntityViewBuilderTest.php +++ b/tests/src/Kernel/EntityViewBuilderTest.php @@ -86,7 +86,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { self::assertCache($expected_cache, $build['#cache']); $expected_html = <<< 'HTML' -
+

Public node

@@ -119,7 +119,7 @@ final class EntityViewBuilderTest extends AbstractTestCase { self::assertCache($expected_cache, $build['#cache']); $expected_html = <<< 'HTML' -
+

Public node