From 054e7b0255f5982d74d33ca3cbbb04ac75729202 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 10 Feb 2022 10:06:53 +0000 Subject: [PATCH 01/23] OEL-1017: Create OE Whitelabel News submodule and import OE Starter Content display and date format configuration. --- modules/oe_whitelabel_news/README.md | 1 + ...e.date_format.oel_whitelabel_news_date.yml | 7 +++ ....entity_view_display.node.oe_news.full.yml | 59 ++++++++++++++++++ ...ntity_view_display.node.oe_news.teaser.yml | 60 +++++++++++++++++++ .../oe_whitelabel_news.info.yml | 7 +++ 5 files changed, 134 insertions(+) create mode 100644 modules/oe_whitelabel_news/README.md create mode 100644 modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml create mode 100644 modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml create mode 100644 modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml create mode 100644 modules/oe_whitelabel_news/oe_whitelabel_news.info.yml diff --git a/modules/oe_whitelabel_news/README.md b/modules/oe_whitelabel_news/README.md new file mode 100644 index 000000000..8affd80ea --- /dev/null +++ b/modules/oe_whitelabel_news/README.md @@ -0,0 +1 @@ +# OpenEuropa Whitelabel News \ No newline at end of file diff --git a/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml b/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml new file mode 100644 index 000000000..4ee008fd3 --- /dev/null +++ b/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml @@ -0,0 +1,7 @@ +langcode: und +status: true +dependencies: { } +id: oel_whitelabel_news_date +label: 'OEL Whitelabel News date' +locked: false +pattern: 'd F Y' diff --git a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml new file mode 100644 index 000000000..629c2d5d5 --- /dev/null +++ b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml @@ -0,0 +1,59 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.oe_news.body + - field.field.node.oe_news.oe_featured_media + - field.field.node.oe_news.oe_publication_date + - field.field.node.oe_news.oe_summary + - node.type.oe_news + module: + - datetime + - text + - user + +id: node.oe_news.full +targetEntityType: node +bundle: oe_news +mode: full +content: + body: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 12 + region: content + links: + settings: { } + third_party_settings: { } + weight: 100 + region: content + oe_featured_media: + type: entity_reference_entity_view + label: hidden + settings: + view_mode: default + link: false + third_party_settings: { } + weight: 10 + region: content + oe_publication_date: + type: datetime_default + label: hidden + settings: + timezone_override: '' + format_type: oel_whitelabel_news_date + third_party_settings: { } + weight: 13 + region: content + oe_summary: + type: basic_string + label: hidden + settings: { } + third_party_settings: { } + weight: 11 + region: content +hidden: + langcode: true + search_api_excerpt: true diff --git a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml new file mode 100644 index 000000000..325bfab2d --- /dev/null +++ b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml @@ -0,0 +1,60 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.oe_news.body + - field.field.node.oe_news.oe_featured_media + - field.field.node.oe_news.oe_publication_date + - field.field.node.oe_news.oe_summary + - node.type.oe_news + module: + - datetime + - text + - user + +id: node.oe_news.teaser +targetEntityType: node +bundle: oe_news +mode: teaser +content: + body: + type: text_default + label: hidden + settings: { } + third_party_settings: { } + weight: 12 + region: content + links: + settings: { } + third_party_settings: { } + weight: 100 + region: content + oe_featured_media: + type: entity_reference_entity_view + label: hidden + settings: + view_mode: default + link: false + third_party_settings: { } + weight: 10 + region: content + oe_publication_date: + type: datetime_default + label: hidden + settings: + timezone_override: '' + format_type: oel_whitelabel_news_date + third_party_settings: { } + weight: 13 + region: content + oe_summary: + type: basic_string + label: hidden + settings: { } + third_party_settings: { } + weight: 11 + region: content +hidden: + langcode: true + search_api_excerpt: true diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml new file mode 100644 index 000000000..f3581dbe7 --- /dev/null +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml @@ -0,0 +1,7 @@ +name: OpenEuropa Whitelabel News +type: module +description: Adds additional functionality to the News module +package: OpenEuropa Whitelabel Theme +core_version_requirement: ^8.9 || ^9.1 +dependencies: + - oe_starter_content:oe_starter_content_news From 88958eedfa3a3e43b9951bd18c28c8d53344fe9c Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 10 Feb 2022 10:09:06 +0000 Subject: [PATCH 02/23] OEL-1017: Create Full and Teaser display templates for News and preprocess the media field for the content banner and card patterns. --- .../oe_whitelabel_news.module | 79 +++++++++++++++++++ .../templates/node--oe-news--full.html.twig | 24 ++++++ .../templates/node--oe-news--teaser.html.twig | 25 ++++++ 3 files changed, 128 insertions(+) create mode 100644 modules/oe_whitelabel_news/oe_whitelabel_news.module create mode 100644 modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig create mode 100644 modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.module b/modules/oe_whitelabel_news/oe_whitelabel_news.module new file mode 100644 index 000000000..4d4579e93 --- /dev/null +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.module @@ -0,0 +1,79 @@ +get('oe_featured_media')->isEmpty()) { + return; + } + + /** @var \Drupal\media\Entity\Media $media */ + $media = $node->get('oe_featured_media')->entity; + if (!$media instanceof MediaInterface) { + // The media entity is not available anymore, bail out. + return; + } + + // Retrieve the correct media translation. + /** @var \Drupal\media\Entity\Media $media */ + $media = \Drupal::service('entity.repository')->getTranslationFromContext($media, $node->language()->getId()); + + // Caches are handled by the formatter usually. Since we are not rendering + // the original render arrays, we need to propagate our caches to the + // paragraph template. + $cacheability = CacheableMetadata::createFromRenderArray($variables); + $cacheability->addCacheableDependency($media); + + // Run access checks on the media entity. + $access = $media->access('view', $variables['user'], TRUE); + $cacheability->addCacheableDependency($access); + if (!$access->isAllowed()) { + $cacheability->applyTo($variables); + return; + } + + // Get the media source. + $source = $media->getSource(); + + $is_image = $source instanceof MediaAvPortalPhotoSource || $source instanceof Image; + + // If it's not an image and not a video, bail out. + if (!$is_image) { + $cacheability->applyTo($variables); + return; + } + + if ($is_image) { + $thumbnail = $media->get('thumbnail')->first(); + $variables['image'] = ImageValueObject::fromStyledImageItem($thumbnail, 'large'); + } + + if ($variables['view_mode'] == 'teaser') { + $variables['image'] = ['#markup' => $variables['image']->getSource()]; + } + + $cacheability->applyTo($variables); +} diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig new file mode 100644 index 000000000..9a7a63d56 --- /dev/null +++ b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * News full display. + */ +#} +{% set badges = [] %} +{{ pattern('content_banner', { + background: 'gray', + title: label, + content: content.oe_summary, + image: image, + meta: [ + content.oe_publication_date|render|striptags, + ], + badges: badges|render +}) }} +
+
+
+ {{ content.body }} +
+
+
diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig new file mode 100644 index 000000000..c1550944b --- /dev/null +++ b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @file + * Search result template. + */ +#} +{% set badges = [] %} +{% set _title %} + {{ label }} +{% endset %} +{{ pattern('card', { + variant: 'search', + title: label, + text: content.oe_summary, + image: image, + content: { + '#type': 'html_tag', + '#tag': 'span', + '#attributes': { + class: 'text-muted text-nowrap me-4-5', + }, + '#value': content.oe_publication_date|render|striptags, + }, + badges: badges|render +}) }} \ No newline at end of file From 5b03dd427c168899cbdc4e105fdc7aba796fb30e Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 10 Feb 2022 10:15:44 +0000 Subject: [PATCH 03/23] OEL-1017: Require oe_starter_content as dependency and update php version to 7.4. --- composer.json | 7 ++++++- docker-compose.yml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 2f2f95552..39b838e3d 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=7.3", + "php": ">=7.4", "cweagans/composer-patches": "^1.7", "drupal/core": "^8.9 || ^9.1", "openeuropa/oe_bootstrap_theme": "0.1.202202072010" @@ -24,6 +24,7 @@ "openeuropa/oe_authentication": "^1.4", "openeuropa/oe_corporate_blocks": "^4.4", "openeuropa/oe_multilingual": "^1.9", + "openeuropa/oe_starter_content": "1.x-dev", "openeuropa/task-runner-drupal-project-symlink": "^1.0", "phpspec/prophecy-phpunit": "^1 || ^2", "easyrdf/easyrdf": "1.0.0 as 0.9.1", @@ -38,6 +39,10 @@ "drupal":{ "type": "composer", "url": "https://packages.drupal.org/8" + }, + "openeuropa/oe_starter_content": { + "type": "git", + "url": "https://github.com/openeuropa/oe_starter_content" } }, "extra": { diff --git a/docker-compose.yml b/docker-compose.yml index 053e590a5..71e0089fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: web: - image: fpfis/httpd-php-dev:7.3 + image: fpfis/httpd-php-dev:7.4 working_dir: /var/www/html ports: - 8080:8080 From 7287bd76ebed1ca0b83fe97a525dc1f5b3110b03 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 10 Feb 2022 10:16:32 +0000 Subject: [PATCH 04/23] OEL-1017: Create rendering tests for full and teaser displays and update drone php version. --- .drone.yml | 2 +- .../src/Functional/ContentNewsRenderTest.php | 151 ++++++++++++++++++ .../src/Functional/ContentRenderTestBase.php | 51 ++++++ 3 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 tests/src/Functional/ContentNewsRenderTest.php create mode 100644 tests/src/Functional/ContentRenderTestBase.php diff --git a/.drone.yml b/.drone.yml index 0d832f6d3..2425155af 100644 --- a/.drone.yml +++ b/.drone.yml @@ -105,4 +105,4 @@ matrix: - lowest - highest PHP_VERSION: - - 7.3 + - 7.4 diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php new file mode 100644 index 000000000..427fa49de --- /dev/null +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -0,0 +1,151 @@ + $this->getTestFiles('image')[0]->uri, + ])->save(); + $media_image = Media::create([ + 'bundle' => 'image', + 'name' => 'Starter Image test', + 'oe_media_image' => [ + [ + 'target_id' => 1, + 'alt' => 'Starter Image test alt', + 'title' => 'Starter Image test title', + ], + ], + ]); + $media_image->save(); + + // Create a News node. + /** @var \Drupal\node\Entity\Node $node */ + $node = $this->getStorage('node')->create([ + 'type' => 'oe_news', + 'title' => 'Test news node', + 'oe_summary' => 'http://www.example.org is a web page', + 'body' => 'News body', + 'oe_publication_date' => [ + 'value' => '2022-02-09T20:00:00', + ], + 'uid' => 1, + 'status' => 1, + ]); + $node->set('oe_featured_media', [$media_image]); + $node->save(); + $this->node = $node; + } + + /** + * Tests that the News page renders correctly. + */ + public function testNewsRendering(): void { + $this->drupalGet($this->node->toUrl()); + + // Build node full view. + $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); + $build = $builder->view($this->node, 'full'); + $render = $this->container->get('renderer')->renderRoot($build); + $crawler = new Crawler($render->__toString()); + + // Assert content banner image. + $picture = $this->assertSession()->elementExists('css', 'img.card-img-top'); + $image = $this->assertSession()->elementExists('css', 'img.rounded-1', $picture); + $this->assertStringContainsString('image-test.png', $image->getAttribute('src')); + $this->assertEquals('Starter Image test alt', $image->getAttribute('alt')); + + // Assert content banner title. + $content_banner = $crawler->filter('.bcl-content-banner'); + $this->assertEquals( + 'Test news node', + trim($content_banner->filter('.card-title')->text()) + ); + // Assert content banner publication date. + $this->assertEquals( + '10 February 2022', + trim($content_banner->filter('.card-body > div.my-4')->text()) + ); + // Assert content banner summary. + $this->assertEquals( + 'http://www.example.org is a web page', + trim($content_banner->filter('.oe-news__oe-summary')->text()) + ); + // Assert the news content. + $this->assertEquals( + 'News body', + trim($crawler->filter('.oe-news__body')->text()) + ); + } + + /** + * Tests that the News page renders correctly. + */ + public function testNewsRenderingTeaser(): void { + + $this->drupalGet($this->node->toUrl()); + + // Build node full view. + $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); + $build = $builder->view($this->node, 'teaser'); + $render = $this->container->get('renderer')->renderRoot($build); + $crawler = new Crawler($render->__toString()); + + // Assert content banner image. + $picture = $this->assertSession()->elementExists('css', 'img.card-img-top'); + $image = $this->assertSession()->elementExists('css', 'img.rounded-1', $picture); + $this->assertStringContainsString('image-test.png', $image->getAttribute('src')); + $this->assertEquals('Starter Image test alt', $image->getAttribute('alt')); + + // Assert content banner title. + $this->assertEquals( + 'Test news node', + trim($crawler->filter('h5.card-title')->text()) + ); + // Assert content banner publication date. + $this->assertEquals( + 'http://www.example.org is a web page', + trim($crawler->filter('p.card-text')->text()) + ); + // Assert content banner publication date. + $this->assertEquals( + '10 February 2022', + trim($crawler->filter('div.card-body > span.text-muted')->text()) + ); + } + +} diff --git a/tests/src/Functional/ContentRenderTestBase.php b/tests/src/Functional/ContentRenderTestBase.php new file mode 100644 index 000000000..2b21eddab --- /dev/null +++ b/tests/src/Functional/ContentRenderTestBase.php @@ -0,0 +1,51 @@ +install(['oe_whitelabel']); + \Drupal::configFactory() + ->getEditable('system.theme') + ->set('default', 'oe_whitelabel') + ->save(); + + // Rebuild the ui_pattern definitions to collect the ones provided by + // oe_whitelabel itself. + \Drupal::service('plugin.manager.ui_patterns')->clearCachedDefinitions(); + } + + /** + * Gets the entity type's storage. + * + * @param string $entity_type_id + * The entity type ID to get a storage for. + * + * @return \Drupal\Core\Entity\EntityStorageInterface + * The entity type's storage. + */ + protected function getStorage(string $entity_type_id): EntityStorageInterface { + return \Drupal::entityTypeManager()->getStorage($entity_type_id); + } + +} From 231db83b8922ad27dafd64c6fc02d4312466c1bf Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 10 Feb 2022 10:35:34 +0000 Subject: [PATCH 05/23] OEL-1017: Use original media instead of an image style when preprocessing the media field for cards. --- modules/oe_whitelabel_news/oe_whitelabel_news.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.module b/modules/oe_whitelabel_news/oe_whitelabel_news.module index 4d4579e93..67bdb0acf 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.module +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.module @@ -68,7 +68,7 @@ function oe_whitelabel_news_preprocess_node__oe_news(&$variables) { if ($is_image) { $thumbnail = $media->get('thumbnail')->first(); - $variables['image'] = ImageValueObject::fromStyledImageItem($thumbnail, 'large'); + $variables['image'] = ImageValueObject::fromImageItem($thumbnail); } if ($variables['view_mode'] == 'teaser') { From e54ff09ffbf281c9850cbad4354233c550cb8f20 Mon Sep 17 00:00:00 2001 From: gilmarfdelima Date: Thu, 10 Feb 2022 16:32:05 +0100 Subject: [PATCH 06/23] OEL-1017: OEL-1017: Update minimal versions of file_link, pathauto and ctools due to drupal 9.2 compatibility on lowest installation. --- composer.json | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 39b838e3d..54989c05b 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,18 @@ }, "require-dev": { "composer/installers": "^1.11", - "drupal/core-composer-scaffold": "^8.9 || ^9.1", - "drupal/config_devel": "~1.2", "drupal/better_exposed_filters": "^5.0", + "drupal/config_devel": "~1.2", + "drupal/core-composer-scaffold": "^8.9 || ^9.1", + "drupal/ctools": "^3.7", "drupal/drupal-extension": "~4.1", + "drupal/file_link": "^2.0.4", + "drupal/pathauto": "^1.8", + "drupal/search_api": "^1.21", + "drupal/search_api_autocomplete": "^1.5", "drush/drush": "^10.3", + "easyrdf/easyrdf": "1.0.0 as 0.9.1", + "egulias/email-validator": "^2.1.22 || ^3.0", "openeuropa/code-review": "1.7", "openeuropa/composer-artifacts": "~0.1", "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", @@ -26,10 +33,7 @@ "openeuropa/oe_multilingual": "^1.9", "openeuropa/oe_starter_content": "1.x-dev", "openeuropa/task-runner-drupal-project-symlink": "^1.0", - "phpspec/prophecy-phpunit": "^1 || ^2", - "easyrdf/easyrdf": "1.0.0 as 0.9.1", - "drupal/search_api": "^1.21", - "drupal/search_api_autocomplete": "^1.5" + "phpspec/prophecy-phpunit": "^1 || ^2" }, "scripts": { "post-install-cmd": "./vendor/bin/run drupal:site-setup", @@ -61,6 +65,12 @@ "web-root": "./build" } }, + "_readme": [ + "Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.", + "Explicit requirement for drupal/file_link due to https://www.drupal.org/project/file_link/issues/3147517. It can be removed when oe_media requires version 2.0.4 or above.", + "Explicit requirement for drupal/pathauto due to D9.2 compatability according to https://www.drupal.org/node/2979476.", + "Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped." + ], "installer-paths": { "build/core": [ "type:drupal-core" From 692208f8fb121f83edb6e215f2ed917642ad1b44 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Fri, 11 Feb 2022 15:37:35 +0000 Subject: [PATCH 07/23] OEL-1017: Update Drupal 9.1 to 9.2. along with its dependencies. --- composer.json | 8 ++++---- modules/oe_whitelabel_news/oe_whitelabel_news.info.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 54989c05b..52522f0b2 100644 --- a/composer.json +++ b/composer.json @@ -8,14 +8,14 @@ "require": { "php": ">=7.4", "cweagans/composer-patches": "^1.7", - "drupal/core": "^8.9 || ^9.1", + "drupal/core": "^8.9 || ^9.2", "openeuropa/oe_bootstrap_theme": "0.1.202202072010" }, "require-dev": { "composer/installers": "^1.11", "drupal/better_exposed_filters": "^5.0", "drupal/config_devel": "~1.2", - "drupal/core-composer-scaffold": "^8.9 || ^9.1", + "drupal/core-composer-scaffold": "^8.9 || ^9.2", "drupal/ctools": "^3.7", "drupal/drupal-extension": "~4.1", "drupal/file_link": "^2.0.4", @@ -25,9 +25,9 @@ "drush/drush": "^10.3", "easyrdf/easyrdf": "1.0.0 as 0.9.1", "egulias/email-validator": "^2.1.22 || ^3.0", - "openeuropa/code-review": "1.7", + "openeuropa/code-review": "^1.7 || ^2.0", "openeuropa/composer-artifacts": "~0.1", - "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", + "openeuropa/drupal-core-require-dev": "^8.9 || ^9.2", "openeuropa/oe_authentication": "^1.4", "openeuropa/oe_corporate_blocks": "^4.4", "openeuropa/oe_multilingual": "^1.9", diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml index f3581dbe7..93cf4f05d 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml @@ -2,6 +2,6 @@ name: OpenEuropa Whitelabel News type: module description: Adds additional functionality to the News module package: OpenEuropa Whitelabel Theme -core_version_requirement: ^8.9 || ^9.1 +core_version_requirement: ^8.9 || ^9.2 dependencies: - oe_starter_content:oe_starter_content_news From 2075ee0aa30e51a910df7659ed46d72433aecc93 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Fri, 11 Feb 2022 15:37:58 +0000 Subject: [PATCH 08/23] OEL-1017: Code standards. --- modules/oe_whitelabel_news/oe_whitelabel_news.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.module b/modules/oe_whitelabel_news/oe_whitelabel_news.module index 67bdb0acf..29cbdacb5 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.module +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.module @@ -5,7 +5,7 @@ * OE Whitelabel theme News. */ -declare(strict_types=1); +declare(strict_types = 1); use Drupal\Core\Cache\CacheableMetadata; use Drupal\media\MediaInterface; From b63de565376314a5976e05a0894d224766b54740 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Fri, 11 Feb 2022 15:38:34 +0000 Subject: [PATCH 09/23] OEL-1017: Clean pattern variable and code standards. --- .../templates/node--oe-news--full.html.twig | 3 +-- .../templates/node--oe-news--teaser.html.twig | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig index 9a7a63d56..9d7a84c30 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig @@ -4,7 +4,6 @@ * News full display. */ #} -{% set badges = [] %} {{ pattern('content_banner', { background: 'gray', title: label, @@ -13,7 +12,7 @@ meta: [ content.oe_publication_date|render|striptags, ], - badges: badges|render + badges: badges|render|default([]) }) }}
diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig index c1550944b..970019a6d 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig @@ -4,13 +4,12 @@ * Search result template. */ #} -{% set badges = [] %} {% set _title %} {{ label }} {% endset %} {{ pattern('card', { variant: 'search', - title: label, + title: _title, text: content.oe_summary, image: image, content: { @@ -21,5 +20,5 @@ }, '#value': content.oe_publication_date|render|striptags, }, - badges: badges|render -}) }} \ No newline at end of file + badges: badges|render|default([]) +}) }} From 1c1e56bc5fd8c4a77580f754519c4e528aa82ae9 Mon Sep 17 00:00:00 2001 From: gilmarfdelima Date: Tue, 15 Feb 2022 10:24:31 +0100 Subject: [PATCH 10/23] OEL-1017: Add config dependencies for module. --- modules/oe_whitelabel_news/oe_whitelabel_news.info.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml index 93cf4f05d..1f3b6b0c6 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml @@ -5,3 +5,9 @@ package: OpenEuropa Whitelabel Theme core_version_requirement: ^8.9 || ^9.2 dependencies: - oe_starter_content:oe_starter_content_news + +config_devel: + install: + - core.date_format.oel_whitelabel_news_date.yml + - core.entity_view_display.node.oe_news.full.yml + - core.entity_view_display.node.oe_news.teaser.yml From ac52df4fcce7a2b1e045e5a3a3ce129f97423ae3 Mon Sep 17 00:00:00 2001 From: Gilmar Lima <57403283+GilNovacomm@users.noreply.github.com> Date: Wed, 16 Feb 2022 14:17:44 +0100 Subject: [PATCH 11/23] OEL-1017: Correct test comments and create test instance node. --- .../src/Functional/ContentNewsRenderTest.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index 427fa49de..d0fd52613 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -30,13 +30,20 @@ class ContentNewsRenderTest extends ContentRenderTestBase { 'oe_whitelabel_news', ]; + /** + * A node to be rendered in diferent display views. + * + * @var \Drupal\node\Entity\Node + */ + protected $node; + /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); - // Create a sample media entity to be embedded. + // Create a sample image media entity to be embedded. File::create([ 'uri' => $this->getTestFiles('image')[0]->uri, ])->save(); @@ -72,9 +79,9 @@ protected function setUp(): void { } /** - * Tests that the News page renders correctly. + * Tests that the News page renders correctly in full display. */ - public function testNewsRendering(): void { + public function testNewsRenderingFull(): void { $this->drupalGet($this->node->toUrl()); // Build node full view. @@ -113,13 +120,13 @@ public function testNewsRendering(): void { } /** - * Tests that the News page renders correctly. + * Tests that the News page renders correctly in teaser display. */ public function testNewsRenderingTeaser(): void { $this->drupalGet($this->node->toUrl()); - // Build node full view. + // Build node teaser view. $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'teaser'); $render = $this->container->get('renderer')->renderRoot($build); @@ -136,7 +143,7 @@ public function testNewsRenderingTeaser(): void { 'Test news node', trim($crawler->filter('h5.card-title')->text()) ); - // Assert content banner publication date. + // Assert content banner content. $this->assertEquals( 'http://www.example.org is a web page', trim($crawler->filter('p.card-text')->text()) From 966f14f0c81c30b83d124e37dc21476e0486df93 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:07:42 +0000 Subject: [PATCH 12/23] OEL-1017: Add whitelabel helper as a dependency. --- modules/oe_whitelabel_news/oe_whitelabel_news.info.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml index 1f3b6b0c6..ba0c28c9c 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.info.yml @@ -1,9 +1,10 @@ name: OpenEuropa Whitelabel News type: module -description: Adds additional functionality to the News module +description: Companion module to OE News providing styling to nodes. package: OpenEuropa Whitelabel Theme core_version_requirement: ^8.9 || ^9.2 dependencies: + - oe_whitelabel:oe_whitelabel_helper - oe_starter_content:oe_starter_content_news config_devel: From 8f3f0cfd651312c070cac04ded84106a3b620ae4 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:09:05 +0000 Subject: [PATCH 13/23] OEL-1017: Correctly name OE News date and update the node displays. --- .../install/core.date_format.oel_whitelabel_news_date.yml | 7 ------- .../install/core.entity_view_display.node.oe_news.full.yml | 2 +- .../core.entity_view_display.node.oe_news.teaser.yml | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml diff --git a/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml b/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml deleted file mode 100644 index 4ee008fd3..000000000 --- a/modules/oe_whitelabel_news/config/install/core.date_format.oel_whitelabel_news_date.yml +++ /dev/null @@ -1,7 +0,0 @@ -langcode: und -status: true -dependencies: { } -id: oel_whitelabel_news_date -label: 'OEL Whitelabel News date' -locked: false -pattern: 'd F Y' diff --git a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml index 629c2d5d5..c7bd5898a 100644 --- a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml +++ b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.full.yml @@ -43,7 +43,7 @@ content: label: hidden settings: timezone_override: '' - format_type: oel_whitelabel_news_date + format_type: oe_whitelabel_news_date third_party_settings: { } weight: 13 region: content diff --git a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml index 325bfab2d..b385718c7 100644 --- a/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml +++ b/modules/oe_whitelabel_news/config/install/core.entity_view_display.node.oe_news.teaser.yml @@ -44,7 +44,7 @@ content: label: hidden settings: timezone_override: '' - format_type: oel_whitelabel_news_date + format_type: oe_whitelabel_news_date third_party_settings: { } weight: 13 region: content From dfc5ca4cddc971a91735a0eb304a6594f768f5f2 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:09:52 +0000 Subject: [PATCH 14/23] OEL-1017: Remove unecessary validation. --- modules/oe_whitelabel_news/oe_whitelabel_news.module | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/oe_whitelabel_news/oe_whitelabel_news.module b/modules/oe_whitelabel_news/oe_whitelabel_news.module index 29cbdacb5..fc89a07f2 100644 --- a/modules/oe_whitelabel_news/oe_whitelabel_news.module +++ b/modules/oe_whitelabel_news/oe_whitelabel_news.module @@ -17,7 +17,6 @@ use Drupal\oe_bootstrap_theme\ValueObject\ImageValueObject; * Implements template_preprocess_node() for the News node type. */ function oe_whitelabel_news_preprocess_node__oe_news(&$variables) { - if ($variables['view_mode'] !== 'full' && $variables['view_mode'] !== 'teaser') { return; } @@ -66,10 +65,8 @@ function oe_whitelabel_news_preprocess_node__oe_news(&$variables) { return; } - if ($is_image) { - $thumbnail = $media->get('thumbnail')->first(); - $variables['image'] = ImageValueObject::fromImageItem($thumbnail); - } + $thumbnail = $media->get('thumbnail')->first(); + $variables['image'] = ImageValueObject::fromImageItem($thumbnail); if ($variables['view_mode'] == 'teaser') { $variables['image'] = ['#markup' => $variables['image']->getSource()]; From 7f6ac3908c2e17ab2d9761ab69189df3e67eca58 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:20:33 +0000 Subject: [PATCH 15/23] OEL-1017: Add dateformat. --- .../install/core.date_format.oe_whitelabel_news_date.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 modules/oe_whitelabel_news/config/install/core.date_format.oe_whitelabel_news_date.yml diff --git a/modules/oe_whitelabel_news/config/install/core.date_format.oe_whitelabel_news_date.yml b/modules/oe_whitelabel_news/config/install/core.date_format.oe_whitelabel_news_date.yml new file mode 100644 index 000000000..373d4583e --- /dev/null +++ b/modules/oe_whitelabel_news/config/install/core.date_format.oe_whitelabel_news_date.yml @@ -0,0 +1,7 @@ +langcode: en +status: true +dependencies: { } +id: oe_whitelabel_news_date +label: 'OE Whitelabel News date' +locked: false +pattern: 'd F Y' From 2d04bc43aacd13f8d59096d31f4b97a2f4015ca9 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:23:00 +0000 Subject: [PATCH 16/23] OEL-1017: Improve template semantics, remove unused variables and general improvements. --- .../templates/node--oe-news--full.html.twig | 32 ++++++++++--------- .../templates/node--oe-news--teaser.html.twig | 30 +++++++++-------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig index 9d7a84c30..e813cbe89 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig @@ -4,20 +4,22 @@ * News full display. */ #} -{{ pattern('content_banner', { - background: 'gray', - title: label, - content: content.oe_summary, - image: image, - meta: [ - content.oe_publication_date|render|striptags, - ], - badges: badges|render|default([]) -}) }} -
-
-
- {{ content.body }} + + {{ pattern('content_banner', { + background: 'gray', + title: label, + content: content.oe_summary, + image: image, + meta: [ + content.oe_publication_date|render|striptags, + ] + }) }} + +
+
+
+ {{ content.body }} +
-
+ diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig index 970019a6d..aa1b353a5 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig @@ -7,18 +7,20 @@ {% set _title %} {{ label }} {% endset %} -{{ pattern('card', { - variant: 'search', - title: _title, - text: content.oe_summary, - image: image, - content: { - '#type': 'html_tag', - '#tag': 'span', - '#attributes': { - class: 'text-muted text-nowrap me-4-5', - }, - '#value': content.oe_publication_date|render|striptags, +{% set _content = { + '#type': 'html_tag', + '#tag': 'span', + '#attributes': { + class: 'text-muted text-nowrap me-4-5', }, - badges: badges|render|default([]) -}) }} + '#value': content.oe_publication_date|render|striptags, +}%} + + {{ pattern('card', { + variant: 'search', + title: _title, + text: content.oe_summary, + image: image, + content: _content + }) }} + From 5011331fede01503c081cfb4abe04c58d4c1a777 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 09:29:30 +0000 Subject: [PATCH 17/23] OEL-1017: Rename base test class, remove browser rendering from test and update display image assertion. --- .../src/Functional/ContentNewsRenderTest.php | 73 ++++++++++--------- ...Base.php => WhitelabelBrowserTestBase.php} | 16 +--- 2 files changed, 39 insertions(+), 50 deletions(-) rename tests/src/Functional/{ContentRenderTestBase.php => WhitelabelBrowserTestBase.php} (60%) diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index d0fd52613..1d6a135c4 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -12,10 +12,8 @@ /** * Tests that the News content type renders correctly. - * - * @group batch1 */ -class ContentNewsRenderTest extends ContentRenderTestBase { +class ContentNewsRenderTest extends WhitelabelBrowserTestBase { use MediaTypeCreationTrait; use TestFileCreationTrait; @@ -24,16 +22,13 @@ class ContentNewsRenderTest extends ContentRenderTestBase { * {@inheritdoc} */ public static $modules = [ - 'system', - 'oe_whitelabel_helper', - 'oe_starter_content_news', 'oe_whitelabel_news', ]; /** - * A node to be rendered in diferent display views. + * A node to be rendered in different display views. * - * @var \Drupal\node\Entity\Node + * @var \Drupal\node\NodeInterface */ protected $node; @@ -62,17 +57,19 @@ protected function setUp(): void { // Create a News node. /** @var \Drupal\node\Entity\Node $node */ - $node = $this->getStorage('node')->create([ - 'type' => 'oe_news', - 'title' => 'Test news node', - 'oe_summary' => 'http://www.example.org is a web page', - 'body' => 'News body', - 'oe_publication_date' => [ - 'value' => '2022-02-09T20:00:00', - ], - 'uid' => 1, - 'status' => 1, - ]); + $node = \Drupal::entityTypeManager() + ->getStorage('node') + ->create([ + 'type' => 'oe_news', + 'title' => 'Test news node', + 'oe_summary' => 'http://www.example.org is a web page', + 'body' => 'News body', + 'oe_publication_date' => [ + 'value' => '2022-02-09T20:00:00', + ], + 'uid' => 1, + 'status' => 1, + ]); $node->set('oe_featured_media', [$media_image]); $node->save(); $this->node = $node; @@ -82,7 +79,9 @@ protected function setUp(): void { * Tests that the News page renders correctly in full display. */ public function testNewsRenderingFull(): void { - $this->drupalGet($this->node->toUrl()); + $node = \Drupal::entityTypeManager() + ->getStorage('node') + ->loadByProperties(['title' => 'Test news node']); // Build node full view. $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); @@ -90,18 +89,23 @@ public function testNewsRenderingFull(): void { $render = $this->container->get('renderer')->renderRoot($build); $crawler = new Crawler($render->__toString()); - // Assert content banner image. - $picture = $this->assertSession()->elementExists('css', 'img.card-img-top'); - $image = $this->assertSession()->elementExists('css', 'img.rounded-1', $picture); - $this->assertStringContainsString('image-test.png', $image->getAttribute('src')); - $this->assertEquals('Starter Image test alt', $image->getAttribute('alt')); - // Assert content banner title. $content_banner = $crawler->filter('.bcl-content-banner'); $this->assertEquals( 'Test news node', trim($content_banner->filter('.card-title')->text()) ); + // Assert content banner image. + $image = $content_banner->filter('img'); + $this->assertCount(1, $image); + $this->assertCount(1, $image->filter('.card-img-top')); + $this->assertStringContainsString( + 'image-test.png', + trim($image->attr('src')) + ); + $this->assertEquals('Starter Image test alt', + $image->attr('alt') + ); // Assert content banner publication date. $this->assertEquals( '10 February 2022', @@ -123,26 +127,25 @@ public function testNewsRenderingFull(): void { * Tests that the News page renders correctly in teaser display. */ public function testNewsRenderingTeaser(): void { - - $this->drupalGet($this->node->toUrl()); - // Build node teaser view. $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'teaser'); $render = $this->container->get('renderer')->renderRoot($build); $crawler = new Crawler($render->__toString()); - // Assert content banner image. - $picture = $this->assertSession()->elementExists('css', 'img.card-img-top'); - $image = $this->assertSession()->elementExists('css', 'img.rounded-1', $picture); - $this->assertStringContainsString('image-test.png', $image->getAttribute('src')); - $this->assertEquals('Starter Image test alt', $image->getAttribute('alt')); - // Assert content banner title. $this->assertEquals( 'Test news node', trim($crawler->filter('h5.card-title')->text()) ); + // Assert content banner image. + $image = $crawler->filter('img'); + $this->assertCount(1, $image); + $this->assertCount(1, $image->filter('.card-img-top')); + $this->assertStringContainsString( + 'image-test.png', + trim($image->attr('src')) + ); // Assert content banner content. $this->assertEquals( 'http://www.example.org is a web page', diff --git a/tests/src/Functional/ContentRenderTestBase.php b/tests/src/Functional/WhitelabelBrowserTestBase.php similarity index 60% rename from tests/src/Functional/ContentRenderTestBase.php rename to tests/src/Functional/WhitelabelBrowserTestBase.php index 2b21eddab..7aae37c3c 100644 --- a/tests/src/Functional/ContentRenderTestBase.php +++ b/tests/src/Functional/WhitelabelBrowserTestBase.php @@ -4,13 +4,12 @@ namespace Drupal\Tests\oe_whitelabel\Functional; -use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Tests\BrowserTestBase; /** * Base class for testing content types. */ -abstract class ContentRenderTestBase extends BrowserTestBase { +abstract class WhitelabelBrowserTestBase extends BrowserTestBase { /** * {@inheritdoc} @@ -35,17 +34,4 @@ protected function setUp(): void { \Drupal::service('plugin.manager.ui_patterns')->clearCachedDefinitions(); } - /** - * Gets the entity type's storage. - * - * @param string $entity_type_id - * The entity type ID to get a storage for. - * - * @return \Drupal\Core\Entity\EntityStorageInterface - * The entity type's storage. - */ - protected function getStorage(string $entity_type_id): EntityStorageInterface { - return \Drupal::entityTypeManager()->getStorage($entity_type_id); - } - } From 993902fc0e37f7900eddba04eff502269fac39a5 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 11:24:06 +0000 Subject: [PATCH 18/23] OEL-1017: Create a template for field oe_publication_date and remove filters from node display. --- ...-node--oe-publication-date--oe-news.html.twig | 16 ++++++++++++++++ .../templates/node--oe-news--full.html.twig | 2 +- .../templates/node--oe-news--teaser.html.twig | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 modules/oe_whitelabel_news/templates/field--node--oe-publication-date--oe-news.html.twig diff --git a/modules/oe_whitelabel_news/templates/field--node--oe-publication-date--oe-news.html.twig b/modules/oe_whitelabel_news/templates/field--node--oe-publication-date--oe-news.html.twig new file mode 100644 index 000000000..c1d557316 --- /dev/null +++ b/modules/oe_whitelabel_news/templates/field--node--oe-publication-date--oe-news.html.twig @@ -0,0 +1,16 @@ +{# +/** + * @file + * Theme override for field oe-publication-date. + */ +#} +{% if label_hidden %} + {% for item in items %} + {{ item.content }} + {% endfor %} +{% else %} + {{ label }} + {% for item in items %} + {{ item.content }} + {% endfor %} +{% endif %} \ No newline at end of file diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig index e813cbe89..26d8251d9 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--full.html.twig @@ -11,7 +11,7 @@ content: content.oe_summary, image: image, meta: [ - content.oe_publication_date|render|striptags, + content.oe_publication_date, ] }) }} diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig index aa1b353a5..2a78044de 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig @@ -13,7 +13,7 @@ '#attributes': { class: 'text-muted text-nowrap me-4-5', }, - '#value': content.oe_publication_date|render|striptags, + '#value': content.oe_publication_date, }%} {{ pattern('card', { From 349724bcd1866fe9d89a821ba4532df459ba011a Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 12:16:12 +0000 Subject: [PATCH 19/23] OEL-1017: Use composer v1 until support for 2 is complete in OpenEuropa. --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 2425155af..9986cca46 100644 --- a/.drone.yml +++ b/.drone.yml @@ -43,6 +43,7 @@ pipeline: volumes: - /cache:/cache commands: + - composer self-update --1 - composer install --ansi --no-suggest --no-progress composer-update-lowest: From 7ecbfe140c62906cde563a14fd755e6013442c58 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 15:16:04 +0000 Subject: [PATCH 20/23] OEL-1017: Set content variable using markup on teaser template and update Functional test node view rendering. --- .../templates/node--oe-news--teaser.html.twig | 11 +++-------- tests/src/Functional/ContentNewsRenderTest.php | 8 ++------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig index 2a78044de..51cb95a61 100644 --- a/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig +++ b/modules/oe_whitelabel_news/templates/node--oe-news--teaser.html.twig @@ -7,14 +7,9 @@ {% set _title %} {{ label }} {% endset %} -{% set _content = { - '#type': 'html_tag', - '#tag': 'span', - '#attributes': { - class: 'text-muted text-nowrap me-4-5', - }, - '#value': content.oe_publication_date, -}%} +{% set _content %} + {{ content.oe_publication_date }} +{% endset %} {{ pattern('card', { variant: 'search', diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index 1d6a135c4..56f5f592e 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -79,15 +79,11 @@ protected function setUp(): void { * Tests that the News page renders correctly in full display. */ public function testNewsRenderingFull(): void { - $node = \Drupal::entityTypeManager() - ->getStorage('node') - ->loadByProperties(['title' => 'Test news node']); - // Build node full view. $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'full'); $render = $this->container->get('renderer')->renderRoot($build); - $crawler = new Crawler($render->__toString()); + $crawler = new Crawler((string)$render); // Assert content banner title. $content_banner = $crawler->filter('.bcl-content-banner'); @@ -131,7 +127,7 @@ public function testNewsRenderingTeaser(): void { $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'teaser'); $render = $this->container->get('renderer')->renderRoot($build); - $crawler = new Crawler($render->__toString()); + $crawler = new Crawler((string)$render); // Assert content banner title. $this->assertEquals( From e8f1771ae76020cbc65e24cf12e83a53e0968344 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 15:22:32 +0000 Subject: [PATCH 21/23] OEL-1017: Code standards. --- tests/src/Functional/ContentNewsRenderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index 56f5f592e..2961f945f 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -83,7 +83,7 @@ public function testNewsRenderingFull(): void { $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'full'); $render = $this->container->get('renderer')->renderRoot($build); - $crawler = new Crawler((string)$render); + $crawler = new Crawler((string) $render); // Assert content banner title. $content_banner = $crawler->filter('.bcl-content-banner'); @@ -127,7 +127,7 @@ public function testNewsRenderingTeaser(): void { $builder = \Drupal::entityTypeManager()->getViewBuilder('node'); $build = $builder->view($this->node, 'teaser'); $render = $this->container->get('renderer')->renderRoot($build); - $crawler = new Crawler((string)$render); + $crawler = new Crawler((string) $render); // Assert content banner title. $this->assertEquals( From c24dc68c002999bd143399e8e5202962bebf23a4 Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Thu, 17 Feb 2022 15:35:58 +0000 Subject: [PATCH 22/23] OEL-1017: Downgrade compose on lowest installation for drone. --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 9986cca46..7621a466d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -52,6 +52,7 @@ pipeline: volumes: - /cache:/cache commands: + - composer self-update --1 - composer update --prefer-lowest --ansi --no-suggest --no-progress when: event: From 3fc38c69c4114a48ec99f81cb7631986c9b361cb Mon Sep 17 00:00:00 2001 From: Gilmar Lima Date: Fri, 18 Feb 2022 08:03:49 +0000 Subject: [PATCH 23/23] OEL-1017: Set variable as protected. --- tests/src/Functional/ContentNewsRenderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index 2961f945f..7681b1c75 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -21,7 +21,7 @@ class ContentNewsRenderTest extends WhitelabelBrowserTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'oe_whitelabel_news', ];