From 07b3a9dc459437ee02463b41f2b648ffc09a8392 Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Wed, 5 Jan 2022 18:39:09 +0200 Subject: [PATCH] EWPP-1830: Update pattern assertions and event rendering test coverage. --- .../src/Plugin/ExtraField/Display/DetailsExtraField.php | 1 + tests/src/Functional/ContentEventRenderTest.php | 9 +++++++++ tests/src/Kernel/EventRenderTest.php | 7 +++++++ tests/src/PatternAssertions/IconsTextAssert.php | 3 ++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DetailsExtraField.php b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DetailsExtraField.php index 8eea2dc979..70a02ac5f9 100755 --- a/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DetailsExtraField.php +++ b/modules/oe_theme_content_event/src/Plugin/ExtraField/Display/DetailsExtraField.php @@ -236,6 +236,7 @@ protected function addRenderableOnlineType(array &$build, ContentEntityInterface $build['#fields']['items'][] = [ 'icon' => 'livestreaming', 'text' => $this->t('Live streaming available'), + 'size' => 's', ]; } } diff --git a/tests/src/Functional/ContentEventRenderTest.php b/tests/src/Functional/ContentEventRenderTest.php index d71149290a..b1fdfa8643 100644 --- a/tests/src/Functional/ContentEventRenderTest.php +++ b/tests/src/Functional/ContentEventRenderTest.php @@ -225,9 +225,11 @@ public function testEventRendering(): void { [ 'icon' => 'file', 'text' => 'Financing', + 'size' => 's', ], [ 'icon' => 'calendar', 'text' => '28 February 2020, 01:00', + 'size' => 's', ], ], ]; @@ -271,9 +273,11 @@ public function testEventRendering(): void { [ 'icon' => 'file', 'text' => 'Financing', + 'size' => 's', ], [ 'icon' => 'calendar', 'text' => "28 February 2020, 01:00\n - 9 March 2020, 01:00", + 'size' => 's', ], ], ]; @@ -328,6 +332,7 @@ public function testEventRendering(): void { $icons_text_expected_values['items'][2] = [ 'icon' => 'location', 'text' => ', Belgium', + 'size' => 's', ]; $icons_text_assert->assertPattern($icons_text_expected_values, $details_list_content->getOuterHtml()); @@ -408,6 +413,7 @@ public function testEventRendering(): void { $icons_text_expected_values['items'][3] = [ 'icon' => 'livestreaming', 'text' => 'Live streaming available', + 'size' => 's', ]; $icons_text_assert->assertPattern($icons_text_expected_values, $details_list_content->getOuterHtml()); @@ -672,12 +678,15 @@ public function testEventRendering(): void { [ 'icon' => 'file', 'text' => 'Financing', + 'size' => 's', ], [ 'icon' => 'calendar', 'text' => "28 February 2020, 01:00\n - 9 March 2020, 01:00", + 'size' => 's', ], [ 'icon' => 'livestreaming', 'text' => 'Live streaming available', + 'size' => 's', ], ], ]; diff --git a/tests/src/Kernel/EventRenderTest.php b/tests/src/Kernel/EventRenderTest.php index ded14f812c..7ebf1f04b8 100644 --- a/tests/src/Kernel/EventRenderTest.php +++ b/tests/src/Kernel/EventRenderTest.php @@ -166,6 +166,7 @@ public function testEventTeaser(): void { [ 'icon' => 'location', 'text' => 'Belgium', + 'size' => 's', ], ], ]), @@ -206,10 +207,12 @@ public function testEventTeaser(): void { [ 'icon' => 'location', 'text' => ', Belgium', + 'size' => 's', ], [ 'icon' => 'livestreaming', 'text' => t('Live streaming available'), + 'size' => 's', ], ], ]); @@ -225,10 +228,12 @@ public function testEventTeaser(): void { [ 'icon' => 'location', 'text' => 'Online only', + 'size' => 's', ], [ 'icon' => 'livestreaming', 'text' => t('Live streaming available'), + 'size' => 's', ], ], ]); @@ -280,10 +285,12 @@ public function testEventTeaser(): void { [ 'icon' => 'location', 'text' => ', Белгия', + 'size' => 's', ], [ 'icon' => 'livestreaming', 'text' => t('Live streaming available'), + 'size' => 's', ], ], ]); diff --git a/tests/src/PatternAssertions/IconsTextAssert.php b/tests/src/PatternAssertions/IconsTextAssert.php index ec7544729f..1156f3fea3 100644 --- a/tests/src/PatternAssertions/IconsTextAssert.php +++ b/tests/src/PatternAssertions/IconsTextAssert.php @@ -47,7 +47,8 @@ protected function assertItems(array $expected_items, Crawler $crawler): void { foreach ($expected_items as $index => $expected_item) { $list_element = $list_elements->eq($index); self::assertEquals($expected_item['text'], trim($list_element->text())); - $icon_element = $list_element->filter('svg.ecl-icon.ecl-icon--m.ecl-u-mr-s use'); + $icon_selector = 'svg.ecl-icon.ecl-icon--' . $expected_item['size'] . '.ecl-u-mr-s use'; + $icon_element = $list_element->filter($icon_selector); $this::assertStringContainsString($expected_item['icon'], $icon_element->attr('xlink:href')); } }