From 16281c1e49176d9a2eefff26165d1d78f7e515f9 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 31 Aug 2022 17:23:21 +0200 Subject: [PATCH 01/16] OEL-1657: Include world flags in the assets. --- bcl-builder.config.js | 8 +++++++- package.json | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bcl-builder.config.js b/bcl-builder.config.js index 34746966b..45d0a880d 100644 --- a/bcl-builder.config.js +++ b/bcl-builder.config.js @@ -18,5 +18,11 @@ module.exports = { }, }, ], - copy: [] + copy: [ + { + from: ["node_modules/@openeuropa/bcl-theme-default/icons/world-flags/*.svg"], + to: path.resolve(outputFolder, "assets/icons/world-flags"), + options: { up: true }, + }, + ] }; diff --git a/package.json b/package.json index b45b93c1e..000f22b7a 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "devDependencies": { "@openeuropa/bcl-builder": "1.1.1", + "@openeuropa/bcl-theme-default": "0.24.1", "chokidar-cli": "^3.0.0", "copyfiles": "2.4.1", "cross-env": "7.0.3", From 7259795c1590b37c0ce1b4de0d315c2bae0398a1 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 31 Aug 2022 17:25:21 +0200 Subject: [PATCH 02/16] OEL-1657: Add a theme implementation to render a world country flag. --- .../oe_whitelabel_helper.module | 25 +++++++++++++++++++ ...e-whitelabel-helper-country-flag.html.twig | 18 +++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-country-flag.html.twig diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module index 23c197371..b6383bff9 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module @@ -30,6 +30,12 @@ function oe_whitelabel_helper_theme($existing, $type, $theme, $path) { 'address_delimiter' => NULL, ], ], + 'oe_whitelabel_helper_country_flag' => [ + 'variables' => [ + 'country_code' => NULL, + 'attributes' => [], + ], + ], 'oe_corporate_blocks_neutral_footer' => [ 'variables' => [ 'corporate_footer' => [], @@ -102,3 +108,22 @@ function oe_whitelabel_helper_requirements_alter(array &$requirements): void { ]; } } + +/** + * Default preprocess function for oe_whitelabel_helper_country_flag. + * + * @param array $variables + * The variables array. + */ +function template_preprocess_oe_whitelabel_helper_country_flag(array &$variables): void { + $theme_extension_list = \Drupal::service('extension.list.theme'); + + $variables['attributes']['class'][] = 'icon--fluid'; + + $image_uri = $theme_extension_list->getPath('oe_whitelabel') . '/assets/icons/world-flags/' . strtolower($variables['country_code']) . '.svg'; + $variables['image'] = [ + '#theme' => 'image__country_flag', + '#uri' => $image_uri, + '#attributes' => $variables['attributes'], + ]; +} diff --git a/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-country-flag.html.twig b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-country-flag.html.twig new file mode 100644 index 000000000..725e4188f --- /dev/null +++ b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-country-flag.html.twig @@ -0,0 +1,18 @@ +{# +/** + * @file + * Default theme implementation for a country flag image. + * + * Available variables: + * - country_code: The ISO 3166-1 alpha-2 code of the country. + * - attributes: HTML attributes to be added to the image. + * - image: The flag image render array. + * + * @see template_preprocess_oe_whitelabel_helper_country_flag() + * + * @ingroup themeable + */ +#} +{% apply spaceless %} +{{ image }} +{% endapply %} From d0f02d3978d872d07bb0bdcfd9116aa77c7e7c82 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 31 Aug 2022 17:31:27 +0200 Subject: [PATCH 03/16] OEL-1657: Add support for country flag in inline address formatter. --- .../schema/oe_whitelabel_helper.schema.yml | 3 ++ .../oe_whitelabel_helper.module | 1 + .../FieldFormatter/AddressInlineFormatter.php | 32 ++++++++++++++++--- ...whitelabel-helper-address-inline.html.twig | 3 +- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml index 837fd610a..3a33b6c1d 100644 --- a/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml +++ b/modules/oe_whitelabel_helper/config/schema/oe_whitelabel_helper.schema.yml @@ -10,6 +10,9 @@ field.formatter.settings.oe_whitelabel_helper_address_inline: sequence: type: boolean label: 'Properties' + show_country_flag: + type: boolean + label: 'Show a country flag together with the address.' condition.plugin.oe_whitelabel_helper_current_component_library: type: condition.plugin mapping: diff --git a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module index b6383bff9..230904f59 100644 --- a/modules/oe_whitelabel_helper/oe_whitelabel_helper.module +++ b/modules/oe_whitelabel_helper/oe_whitelabel_helper.module @@ -28,6 +28,7 @@ function oe_whitelabel_helper_theme($existing, $type, $theme, $path) { 'address' => NULL, 'address_items' => [], 'address_delimiter' => NULL, + 'country_flag' => NULL, ], ], 'oe_whitelabel_helper_country_flag' => [ diff --git a/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php b/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php index e004fcd6a..337eb24c8 100644 --- a/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php +++ b/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php @@ -34,6 +34,7 @@ public static function defaultSettings() { return [ 'delimiter' => ', ', 'properties' => [], + 'show_country_flag' => FALSE, ]; } @@ -48,7 +49,6 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#description' => $this->t('Specify delimiter between address items.'), '#required' => TRUE, ]; - $form['properties'] = [ '#type' => 'checkboxes', '#title' => $this->t('Properties'), @@ -56,6 +56,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) { '#description' => $this->t('Which properties should be displayed. Leave empty for all.'), '#options' => $this->getPropertiesDisplayOptions(), ]; + $form['show_country_flag'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Show country flag'), + '#default_value' => $this->getSetting('show_country_flag'), + ]; return $form; } @@ -64,14 +69,20 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - return [ + $summary = [ $this->t('Delimiter: @delimiter', [ '@delimiter' => $this->getSetting('delimiter'), ]), $this->t('Properties: @properties', [ '@properties' => implode(', ', $this->getActiveProperties()), - ]), + ]) ]; + + if ($this->getSetting('show_country_flag')) { + $summary[] = $this->t('Show country flag'); + } + + return $summary; } /** @@ -125,7 +136,7 @@ protected function viewElement(AddressInterface $address, $langcode) { $items = $this->extractAddressItems($format_string, $address_elements); - return [ + $build = [ '#theme' => 'oe_whitelabel_helper_address_inline', '#address' => $address, '#address_items' => $items, @@ -136,6 +147,19 @@ protected function viewElement(AddressInterface $address, $langcode) { ], ], ]; + + if ($this->getSetting('show_country_flag')) { + $build['#country_flag'] = [ + '#theme' => 'oe_whitelabel_helper_country_flag', + '#country_code' => $country_code, + '#attributes' => [ + 'class' => ['me-2'], + 'alt' => $countries[$country_code], + ], + ]; + } + + return $build; } /** diff --git a/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig index 5359af844..1b29e262b 100644 --- a/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig +++ b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig @@ -7,10 +7,11 @@ * - address: Address object. * - address_items: Address items. * - address_delimiter: Delimiter between address items. + * - country_flag: The country address flag. Optional. * * @ingroup themeable */ #} - {{ address_items|join(address_delimiter) }} + {{ country_flag }} {{ address_items|join(address_delimiter) }} From 6336633db6337a3322f0806008f4bf4a9ac62ffa Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 31 Aug 2022 18:12:16 +0200 Subject: [PATCH 04/16] OEL-1657: Update configuration for new and existing installations. --- ...tion.oe_cx_project_stakeholder.default.yml | 1 + ...oe_organisation.oe_stakeholder.default.yml | 87 +++++++++++++++++++ .../oe_whitelabel_extra_project.install | 1 + ...e_whitelabel_extra_project.post_update.php | 22 +++++ ...ity_view_display.node.oe_sc_event.full.yml | 1 + ...e_whitelabel_starter_event.post_update.php | 15 ++++ 6 files changed, 127 insertions(+) create mode 100644 modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml diff --git a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml index f1faedb5a..b0f10440a 100644 --- a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml +++ b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml @@ -51,6 +51,7 @@ content: label: hidden settings: delimiter: ', ' + show_country_flag: true third_party_settings: { } weight: 2 region: content diff --git a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml new file mode 100644 index 000000000..e2ddfc164 --- /dev/null +++ b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml @@ -0,0 +1,87 @@ +langcode: en +status: true +dependencies: + config: + - field.field.oe_organisation.oe_stakeholder.oe_acronym + - field.field.oe_organisation.oe_stakeholder.oe_address + - field.field.oe_organisation.oe_stakeholder.oe_contact_url + - field.field.oe_organisation.oe_stakeholder.oe_logo + - field.field.oe_organisation.oe_stakeholder.oe_website + - oe_content_entity_organisation.oe_organisation_type.oe_stakeholder + module: + - address + - link +id: oe_organisation.oe_stakeholder.default +targetEntityType: oe_organisation +bundle: oe_stakeholder +mode: default +content: + created: + label: hidden + type: timestamp + weight: 0 + region: content + settings: + date_format: medium + custom_date_format: '' + timezone: '' + third_party_settings: { } + name: + label: hidden + type: string + weight: -5 + region: content + settings: + link_to_entity: false + third_party_settings: { } + oe_acronym: + weight: 1 + label: above + settings: + link_to_entity: false + third_party_settings: { } + type: string + region: content + oe_address: + weight: 3 + label: above + settings: { } + third_party_settings: { } + type: address_default + region: content + oe_contact_url: + weight: 5 + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content + oe_logo: + type: entity_reference_entity_view + weight: 2 + label: above + settings: + view_mode: default + link: false + third_party_settings: { } + region: content + oe_website: + weight: 4 + label: above + settings: + trim_length: 80 + url_only: false + url_plain: false + rel: '' + target: '' + third_party_settings: { } + type: link + region: content +hidden: + langcode: true + status: true diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.install b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.install index 782c6ebd1..4736ee949 100644 --- a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.install +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.install @@ -24,6 +24,7 @@ function oe_whitelabel_extra_project_install($is_syncing): void { 'core.entity_form_display.node.oe_project.default', 'core.entity_form_display.oe_organisation.oe_cx_project_stakeholder.default', 'core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default', + 'core.entity_view_display.oe_organisation.oe_stakeholder.default', ]; ConfigImporter::importMultiple('module', 'oe_whitelabel_extra_project', '/config/overrides/', $configs); diff --git a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php index f9fb6cab4..e1d67f6fe 100644 --- a/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php +++ b/modules/oe_whitelabel_extra_project/oe_whitelabel_extra_project.post_update.php @@ -21,3 +21,25 @@ function oe_whitelabel_extra_project_post_update_00001(): void { ]; ConfigImporter::importMultiple('module', 'oe_whitelabel_extra_project', '/config/post_updates/00001_decimal_budget_fields', $configs, TRUE); } + +/** + * Enable the country flag rendering in project organisations. + */ +function oe_whitelabel_extra_project_post_update_00002(&$sandbox) { + $view_display_ids = [ + 'oe_organisation.oe_cx_project_stakeholder.default', + 'oe_organisation.oe_stakeholder.default', + ]; + + /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay[] $view_displays */ + $view_displays = \Drupal::entityTypeManager()->getStorage('entity_view_display')->loadMultiple($view_display_ids); + foreach ($view_displays as $view_display) { + $component = $view_display->getComponent('oe_address'); + if ($component === NULL) { + continue; + } + + $component['settings']['show_country_flag'] = TRUE; + $view_display->setComponent('oe_address', $component)->save(); + } +} diff --git a/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml b/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml index 56b965dcc..6cc4a865d 100644 --- a/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml +++ b/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml @@ -55,6 +55,7 @@ content: label: inline settings: delimiter: ', ' + show_country_flag: true third_party_settings: { } weight: 2 region: content diff --git a/modules/oe_whitelabel_starter_event/oe_whitelabel_starter_event.post_update.php b/modules/oe_whitelabel_starter_event/oe_whitelabel_starter_event.post_update.php index c7f13088e..01ffc8085 100644 --- a/modules/oe_whitelabel_starter_event/oe_whitelabel_starter_event.post_update.php +++ b/modules/oe_whitelabel_starter_event/oe_whitelabel_starter_event.post_update.php @@ -56,3 +56,18 @@ function oe_whitelabel_starter_event_post_update_00003(): void { function oe_whitelabel_starter_event_post_update_00004(): void { ConfigImporter::importSingle('module', 'oe_whitelabel_starter_event', '/config/post_updates/00004_teaser_location', 'core.entity_view_display.node.oe_sc_event.teaser'); } + +/** + * Render the country flag for the event address. + */ +function oe_whitelabel_starter_event_post_update_00005(): void { + /** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $view_display */ + $view_display = \Drupal::entityTypeManager()->getStorage('entity_view_display')->load('node.oe_sc_event.full'); + $component = $view_display->getComponent('oe_sc_event_location'); + if ($component === NULL) { + return; + } + + $component['settings']['show_country_flag'] = TRUE; + $view_display->setComponent('oe_sc_event_location', $component)->save(); +} From 9d1d794f72a03dde6fb5ee063de1b2fabb0a3e71 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 31 Aug 2022 18:30:08 +0200 Subject: [PATCH 05/16] OEL-1657: Add test coverage. --- .../AddressInlineFormatterTest.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php index 277ff223f..367093b6e 100644 --- a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php +++ b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php @@ -42,7 +42,29 @@ public function testInlineFormatterAddress(): void { $cloned_entity->{$this->fieldName} = $data['address']; $this->renderEntityFields($cloned_entity, $this->display); $this->assertRaw($data['expected']); - unset($cloned_entity); + $this->assertNoRaw('display->setComponent($this->fieldName, [ + 'type' => 'oe_whitelabel_helper_address_inline', + 'settings' => [ + 'show_country_flag' => TRUE, + ], + ]); + $this->display->save(); + $country_flags_folder = $this->container->get('extension.list.theme')->getPath('oe_whitelabel') . '/assets/icons/world-flags/'; + $file_url_generator = $this->container->get('file_url_generator'); + $country_repository = $this->container->get('address.country_repository'); + + foreach ($this->addressFieldTestData() as $data) { + $entity->set($this->fieldName, $data['address']); + $this->renderEntityFields($entity, $this->display); + + $country_code = strtolower($data['address']['country_code']); + $country_flag_path = $file_url_generator->generateString($country_flags_folder . $country_code . '.svg'); + $country_flag_html = sprintf('%s', $country_repository->get($country_code)->getName(), $country_flag_path); + $this->assertRaw($country_flag_html . ' ' . $data['expected']); } } From 5927ab135393cfff9dd3ad83d9357e36c5028753 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 31 Jul 2023 17:21:05 +0200 Subject: [PATCH 06/16] OEL-1657: Update BCL and flag paths. --- bcl-builder.config.js | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bcl-builder.config.js b/bcl-builder.config.js index 45d0a880d..9c7f23142 100644 --- a/bcl-builder.config.js +++ b/bcl-builder.config.js @@ -20,7 +20,7 @@ module.exports = { ], copy: [ { - from: ["node_modules/@openeuropa/bcl-theme-default/icons/world-flags/*.svg"], + from: ["node_modules/@openeuropa/bcl-theme-default/icons/world-flags/4x3/*.svg"], to: path.resolve(outputFolder, "assets/icons/world-flags"), options: { up: true }, }, diff --git a/package.json b/package.json index 000f22b7a..864da8249 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,11 @@ }, "devDependencies": { "@openeuropa/bcl-builder": "1.1.1", - "@openeuropa/bcl-theme-default": "0.24.1", + "@openeuropa/bcl-theme-default": "1.1.1", "chokidar-cli": "^3.0.0", "copyfiles": "2.4.1", "cross-env": "7.0.3", - "glob": "7.1.7", + "glob": "10.0.0", "npm-run-all": "4.1.5" } } From 255956bad8198a4578b7d8325304b77e618aa966 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Mon, 31 Jul 2023 17:26:13 +0200 Subject: [PATCH 07/16] OEL-1657: Coding standards. --- .../src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php b/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php index 337eb24c8..fe4091ca5 100644 --- a/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php +++ b/modules/oe_whitelabel_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php @@ -75,7 +75,7 @@ public function settingsSummary() { ]), $this->t('Properties: @properties', [ '@properties' => implode(', ', $this->getActiveProperties()), - ]) + ]), ]; if ($this->getSetting('show_country_flag')) { From 49a52c455c6b1fb39e0123337c8e31c2e6609ab4 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 1 Aug 2023 16:09:52 +0200 Subject: [PATCH 08/16] OEL-1657: Uniform all tests to extend the base whitelabel kernel test. --- .../src/Kernel/ContactFormRenderTest.php | 16 +-- .../sort/FloatEndSortWidgetTest.php | 11 ++ .../src/Kernel/AbstractKernelTestBase.php | 105 ------------------ .../Kernel/Paragraphs/ParagraphsTestBase.php | 3 +- .../tests/src/Kernel/SearchBlockTest.php | 16 +-- tests/src/Kernel/AuthenticationBlockTest.php | 20 +--- .../Kernel/ContentLanguageSwitcherTest.php | 24 +--- tests/src/Kernel/FacetsFormTest.php | 15 +-- tests/src/Kernel/FooterBlockTest.php | 28 ++--- tests/src/Kernel/MultilingualBlockTest.php | 16 +-- tests/src/Kernel/ProjectRenderTest.php | 4 +- tests/src/Kernel/SiteBrandingBlockTest.php | 12 +- 12 files changed, 37 insertions(+), 233 deletions(-) delete mode 100644 modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php diff --git a/modules/oe_whitelabel_contact_forms/tests/src/Kernel/ContactFormRenderTest.php b/modules/oe_whitelabel_contact_forms/tests/src/Kernel/ContactFormRenderTest.php index 3f9330160..26b3dafb7 100644 --- a/modules/oe_whitelabel_contact_forms/tests/src/Kernel/ContactFormRenderTest.php +++ b/modules/oe_whitelabel_contact_forms/tests/src/Kernel/ContactFormRenderTest.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\oe_whitelabel_contact_forms\Kernel; use Drupal\contact\Entity\ContactForm; -use Drupal\KernelTests\KernelTestBase; +use Drupal\Tests\oe_whitelabel\Kernel\AbstractKernelTestBase; use Drupal\Tests\oe_whitelabel\PatternAssertions\DescriptionListAssert; use Drupal\Tests\sparql_entity_storage\Traits\SparqlConnectionTrait; use Symfony\Component\DomCrawler\Crawler; @@ -13,7 +13,7 @@ /** * Tests that our contact forms renders with right markup. */ -class ContactFormRenderTest extends KernelTestBase { +class ContactFormRenderTest extends AbstractKernelTestBase { use SparqlConnectionTrait; @@ -21,14 +21,9 @@ class ContactFormRenderTest extends KernelTestBase { * {@inheritdoc} */ protected static $modules = [ - 'oe_bootstrap_theme_helper', - 'ui_patterns', - 'ui_patterns_library', 'path', 'path_alias', 'options', - 'user', - 'system', 'telephone', 'contact', 'contact_storage', @@ -45,16 +40,9 @@ class ContactFormRenderTest extends KernelTestBase { protected function setUp(): void { parent::setUp(); - \Drupal::service('theme_installer')->install(['oe_whitelabel']); $this->installEntitySchema('path_alias'); $this->installEntitySchema('contact_message'); - $this->installEntitySchema('user'); - $this->installSchema('system', 'sequences'); - \Drupal::configFactory() - ->getEditable('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); $this->setUpSparql(); } diff --git a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/better_exposed_filters/sort/FloatEndSortWidgetTest.php b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/better_exposed_filters/sort/FloatEndSortWidgetTest.php index e60b61624..ac400a615 100644 --- a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/better_exposed_filters/sort/FloatEndSortWidgetTest.php +++ b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/better_exposed_filters/sort/FloatEndSortWidgetTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\oe_whitelabel_helper\Kernel\Plugin\better_exposed_filters\sort; +use Drupal\Core\Site\Settings; use Drupal\Tests\better_exposed_filters\Kernel\BetterExposedFiltersKernelTestBase; use Drupal\views\Views; use Symfony\Component\DomCrawler\Crawler; @@ -39,6 +40,16 @@ class FloatEndSortWidgetTest extends BetterExposedFiltersKernelTestBase { protected function setUp($import_test_views = TRUE): void { parent::setUp($import_test_views); + // Replicate 'file_scan_ignore_directories' from settings.php. + $settings = Settings::getAll(); + $settings['file_scan_ignore_directories'] = [ + 'node_modules', + 'bower_components', + 'vendor', + 'build', + ]; + new Settings($settings); + // @todo Use bef_test once it's fixed for d10. // @see https://www.drupal.org/project/better_exposed_filters/issues/3365130 $this->installConfig(['oewt_views_test']); diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php deleted file mode 100644 index cfdbd3761..000000000 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/AbstractKernelTestBase.php +++ /dev/null @@ -1,105 +0,0 @@ -installEntitySchema('user'); - $this->installSchema('system', 'sequences'); - $this->installConfig(['user']); - $this->installConfig([ - 'system', - 'image', - 'responsive_image', - 'oe_bootstrap_theme_helper', - 'oe_whitelabel_helper', - ]); - - $this->container->get('theme_installer')->install(['oe_whitelabel']); - $this->config('system.theme')->set('default', 'oe_whitelabel')->save(); - $this->container->set('theme.registry', NULL); - - // Call the install hook of the User module which creates the Anonymous user - // and User 1. This is needed because the Anonymous user is loaded to - // provide the current User context which is needed in places like route - // enhancers. - // @see CurrentUserContext::getRuntimeContexts(). - // @see EntityConverter::convert(). - module_load_include('install', 'user'); - user_install(); - } - - /** - * Get fixture content. - * - * @param string $filepath - * File path. - * - * @return array - * A set of test data. - */ - protected function getFixtureContent(string $filepath): array { - return Yaml::parse(file_get_contents(__DIR__ . "/fixtures/{$filepath}")); - } - - /** - * Builds and returns the renderable array for a block. - * - * @param string $block_id - * The ID of the block. - * @param array $config - * An array of configuration. - * - * @return array - * A renderable array representing the content of the block. - */ - protected function buildBlock(string $block_id, array $config): array { - /** @var \Drupal\Core\Block\BlockBase $plugin */ - $plugin = $this->container->get('plugin.manager.block')->createInstance($block_id, $config); - - // Inject runtime contexts. - if ($plugin instanceof ContextAwarePluginInterface) { - $contexts = $this->container->get('context.repository')->getRuntimeContexts($plugin->getContextMapping()); - $this->container->get('context.handler')->applyContextMapping($plugin, $contexts); - } - - return $plugin->build(); - } - -} diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php index b7a8fec5a..d835f74af 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; use Drupal\paragraphs\ParagraphInterface; -use Drupal\Tests\oe_whitelabel_paragraphs\Kernel\AbstractKernelTestBase; +use Drupal\Tests\oe_bootstrap_theme\Kernel\AbstractKernelTestBase; /** * Base class for paragraphs tests. @@ -46,7 +46,6 @@ abstract class ParagraphsTestBase extends AbstractKernelTestBase { 'paragraphs', 'text', 'typed_link', - 'user', 'views', ]; diff --git a/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php b/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php index 8a8dd84a2..34e0c37bf 100644 --- a/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php +++ b/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php @@ -4,15 +4,15 @@ namespace Drupal\Tests\oe_whitelabel_search\Kernel; -use Drupal\KernelTests\KernelTestBase; use Drupal\search_api_autocomplete\Entity\Search; +use Drupal\Tests\oe_whitelabel\Kernel\AbstractKernelTestBase; use Drupal\Tests\user\Traits\UserCreationTrait; use Symfony\Component\DomCrawler\Crawler; /** * Tests the Search Block rendering. */ -class SearchBlockTest extends KernelTestBase { +class SearchBlockTest extends AbstractKernelTestBase { use UserCreationTrait; @@ -23,19 +23,13 @@ class SearchBlockTest extends KernelTestBase { 'block', 'entity_test', 'field', - 'oe_bootstrap_theme_helper', 'oe_whitelabel_search', 'search_api', 'search_api_autocomplete', 'search_api_autocomplete_test', 'search_api_db', 'search_api_test', - 'system', 'text', - 'ui_patterns', - 'ui_patterns_library', - 'ui_patterns_settings', - 'user', 'views', ]; @@ -45,12 +39,6 @@ class SearchBlockTest extends KernelTestBase { protected function setUp(): void { parent::setUp(); - \Drupal::service('theme_installer')->install(['oe_whitelabel']); - - $this->config('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); - $this->installSchema('search_api', ['search_api_item']); $this->installEntitySchema('entity_test_mulrev_changed'); $this->installEntitySchema('search_api_task'); diff --git a/tests/src/Kernel/AuthenticationBlockTest.php b/tests/src/Kernel/AuthenticationBlockTest.php index ccb23a16c..7790e36f9 100644 --- a/tests/src/Kernel/AuthenticationBlockTest.php +++ b/tests/src/Kernel/AuthenticationBlockTest.php @@ -4,13 +4,12 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; -use Drupal\KernelTests\KernelTestBase; use Symfony\Component\DomCrawler\Crawler; /** * Tests the OE Authentication LoginBlock rendering. */ -class AuthenticationBlockTest extends KernelTestBase { +class AuthenticationBlockTest extends AbstractKernelTestBase { /** * {@inheritdoc} @@ -20,25 +19,8 @@ class AuthenticationBlockTest extends KernelTestBase { 'cas', 'externalauth', 'oe_authentication', - 'oe_bootstrap_theme_helper', - 'system', - 'ui_patterns', - 'ui_patterns_library', - 'user', ]; - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - \Drupal::service('theme_installer')->install(['oe_whitelabel']); - $this->config('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); - } - /** * Tests the rendering of the authentication block. */ diff --git a/tests/src/Kernel/ContentLanguageSwitcherTest.php b/tests/src/Kernel/ContentLanguageSwitcherTest.php index 6af5dceb9..bdec322d2 100644 --- a/tests/src/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -4,7 +4,6 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; -use Drupal\KernelTests\KernelTestBase; use Drupal\node\Entity\Node; use Drupal\user\Entity\User; use Symfony\Component\DomCrawler\Crawler; @@ -13,7 +12,7 @@ /** * Test content language switcher rendering. */ -class ContentLanguageSwitcherTest extends KernelTestBase { +class ContentLanguageSwitcherTest extends AbstractKernelTestBase { /** * {@inheritdoc} @@ -21,17 +20,10 @@ class ContentLanguageSwitcherTest extends KernelTestBase { protected static $modules = [ 'block', 'content_translation', - 'daterange_compact', 'language', 'locale', - 'node', - 'oe_bootstrap_theme_helper', - 'oe_corporate_blocks', 'oe_multilingual', - 'oe_whitelabel_helper', 'oe_whitelabel_multilingual', - 'system', - 'user', ]; /** @@ -40,10 +32,7 @@ class ContentLanguageSwitcherTest extends KernelTestBase { protected function setUp(): void { parent::setUp(); - $this->installEntitySchema('user'); - $this->installSchema('system', 'sequences'); $this->installSchema('user', ['users_data']); - $this->installConfig(['user']); $this->installSchema('locale', [ 'locales_location', @@ -64,17 +53,6 @@ protected function setUp(): void { $this->container->get('module_handler')->loadInclude('oe_multilingual', 'install'); oe_multilingual_install(FALSE); - $this->container->get('theme_installer')->install(['oe_whitelabel']); - $this->config('system.theme')->set('default', 'oe_whitelabel')->save(); - - // Call the installation hook of the User module which creates the - // Anonymous user and User 1. This is needed because the Anonymous user - // is loaded to provide the current User context which is needed - // in places like route enhancers. - // @see CurrentUserContext::getRuntimeContexts(). - // @see EntityConverter::convert(). - $this->container->get('module_handler')->loadInclude('oe_multilingual', 'install'); - user_install(); \Drupal::currentUser()->setAccount(User::load(1)); \Drupal::service('kernel')->rebuildContainer(); diff --git a/tests/src/Kernel/FacetsFormTest.php b/tests/src/Kernel/FacetsFormTest.php index ebeb0213c..d3e0e6c31 100644 --- a/tests/src/Kernel/FacetsFormTest.php +++ b/tests/src/Kernel/FacetsFormTest.php @@ -4,13 +4,12 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; -use Drupal\KernelTests\KernelTestBase; use Symfony\Component\DomCrawler\Crawler; /** * Tests the Facets Form rendering. */ -class FacetsFormTest extends KernelTestBase { +class FacetsFormTest extends AbstractKernelTestBase { /** * {@inheritdoc} @@ -21,7 +20,6 @@ class FacetsFormTest extends KernelTestBase { 'facets', 'facets_form', 'field', - 'oe_bootstrap_theme_helper', 'rest', 'search_api', 'search_api_db', @@ -30,12 +28,7 @@ class FacetsFormTest extends KernelTestBase { 'search_api_test_example_content', 'search_api_test_views', 'serialization', - 'system', 'text', - 'ui_patterns', - 'ui_patterns_library', - 'ui_patterns_settings', - 'user', 'views', ]; @@ -54,12 +47,6 @@ protected function setUp(): void { 'search_api_test_db', ]); $this->installConfig('search_api_test_views'); - - \Drupal::service('theme_installer')->install(['oe_whitelabel']); - - $this->config('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); } /** diff --git a/tests/src/Kernel/FooterBlockTest.php b/tests/src/Kernel/FooterBlockTest.php index 85d98a2b0..563c5af31 100644 --- a/tests/src/Kernel/FooterBlockTest.php +++ b/tests/src/Kernel/FooterBlockTest.php @@ -4,28 +4,36 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; -use Drupal\Tests\sparql_entity_storage\Kernel\SparqlKernelTestBase; +use Drupal\Tests\sparql_entity_storage\Traits\SparqlConnectionTrait; use Symfony\Component\DomCrawler\Crawler; /** * Tests the EU and the EC corporate Footer blocks rendering. */ -class FooterBlockTest extends SparqlKernelTestBase { +class FooterBlockTest extends AbstractKernelTestBase { + + use SparqlConnectionTrait; /** * {@inheritdoc} */ protected static $modules = [ 'block', - 'oe_bootstrap_theme_helper', 'oe_corporate_blocks', 'oe_corporate_site_info', - 'oe_whitelabel_helper', 'rdf_skos', - 'system', - 'user', + 'sparql_entity_storage', ]; + /** + * {@inheritdoc} + */ + protected function bootEnvironment(): void { + parent::bootEnvironment(); + + $this->setUpSparql(); + } + /** * {@inheritdoc} */ @@ -35,15 +43,9 @@ protected function setUp(): void { $this->installConfig([ 'oe_corporate_site_info', 'oe_corporate_blocks', + 'sparql_entity_storage', ]); - \Drupal::service('theme_installer')->install(['oe_whitelabel']); - - \Drupal::configFactory() - ->getEditable('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); - \Drupal::configFactory() ->getEditable('system.site') ->set('name', 'Footer block test website') diff --git a/tests/src/Kernel/MultilingualBlockTest.php b/tests/src/Kernel/MultilingualBlockTest.php index b441d9560..310955694 100644 --- a/tests/src/Kernel/MultilingualBlockTest.php +++ b/tests/src/Kernel/MultilingualBlockTest.php @@ -4,13 +4,12 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; -use Drupal\KernelTests\KernelTestBase; use Symfony\Component\DomCrawler\Crawler; /** * Tests the OE Multilingual Block rendering. */ -class MultilingualBlockTest extends KernelTestBase { +class MultilingualBlockTest extends AbstractKernelTestBase { /** * {@inheritdoc} @@ -21,17 +20,12 @@ class MultilingualBlockTest extends KernelTestBase { 'ctools', 'language', 'locale', - 'oe_bootstrap_theme_helper', 'oe_multilingual', 'oe_whitelabel_multilingual', 'path', 'path_alias', 'pathauto', - 'system', 'token', - 'ui_patterns', - 'ui_patterns_library', - 'user', ]; /** @@ -40,14 +34,6 @@ class MultilingualBlockTest extends KernelTestBase { protected function setUp(): void { parent::setUp(); - \Drupal::service('theme_installer')->install(['oe_whitelabel']); - - $this->config('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); - - $this->container->set('theme.registry', NULL); - $this->installSchema('locale', [ 'locales_location', 'locales_target', diff --git a/tests/src/Kernel/ProjectRenderTest.php b/tests/src/Kernel/ProjectRenderTest.php index a3c590797..9dc7f7e33 100644 --- a/tests/src/Kernel/ProjectRenderTest.php +++ b/tests/src/Kernel/ProjectRenderTest.php @@ -27,9 +27,7 @@ class ProjectRenderTest extends ContentRenderTestBase { 'oe_content_extra', 'oe_content_extra_project', 'oe_whitelabel_extra_project', - 'system', 'twig_field_value', - 'user', ]; /** @@ -46,7 +44,7 @@ protected function setUp(): void { 'oe_whitelabel_extra_project', ]); - module_load_include('install', 'oe_whitelabel_extra_project'); + $this->container->get('module_handler')->loadInclude('oe_whitelabel_extra_project', 'install'); oe_whitelabel_extra_project_install(FALSE); } diff --git a/tests/src/Kernel/SiteBrandingBlockTest.php b/tests/src/Kernel/SiteBrandingBlockTest.php index 51219d329..0612a0605 100644 --- a/tests/src/Kernel/SiteBrandingBlockTest.php +++ b/tests/src/Kernel/SiteBrandingBlockTest.php @@ -5,22 +5,18 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; use Drupal\Core\Url; -use Drupal\KernelTests\KernelTestBase; use Symfony\Component\DomCrawler\Crawler; /** * Tests the Site Branding Block rendering. */ -class SiteBrandingBlockTest extends KernelTestBase { +class SiteBrandingBlockTest extends AbstractKernelTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'block', - 'oe_bootstrap_theme_helper', - 'system', - 'user', ]; /** @@ -29,7 +25,6 @@ class SiteBrandingBlockTest extends KernelTestBase { protected function setUp(): void { parent::setUp(); - \Drupal::service('theme_installer')->install(['oe_whitelabel']); $url = '/' . \Drupal::service('extension.list.theme')->getPath('oe_whitelabel') . '/logo.svg'; \Drupal::configFactory() @@ -37,11 +32,6 @@ protected function setUp(): void { ->set('logo', ['url' => $url]) ->save(); - \Drupal::configFactory() - ->getEditable('system.theme') - ->set('default', 'oe_whitelabel') - ->save(); - \Drupal::configFactory() ->getEditable('system.site') ->set('name', 'Site name') From dace003a79e5ad52ff59517affee786375bc143a Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 1 Aug 2023 16:40:34 +0200 Subject: [PATCH 09/16] OEL-1657: Fix the inline address formatter test. --- .../AddressInlineFormatterTest.php | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php index 367093b6e..89985b31c 100644 --- a/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php +++ b/modules/oe_whitelabel_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/AddressInlineFormatterTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\oe_whitelabel_helper\Kernel\Plugin\Field\FieldFormatter; +use Drupal\Core\Site\Settings; use Drupal\entity_test\Entity\EntityTest; use Drupal\Tests\address\Kernel\Formatter\FormatterTestBase; @@ -25,6 +26,16 @@ class AddressInlineFormatterTest extends FormatterTestBase { protected function setUp(): void { parent::setUp(); + // Replicate 'file_scan_ignore_directories' from settings.php. + $settings = Settings::getAll(); + $settings['file_scan_ignore_directories'] = [ + 'node_modules', + 'bower_components', + 'vendor', + 'build', + ]; + new Settings($settings); + $this->createField('address', 'oe_whitelabel_helper_address_inline'); } @@ -32,7 +43,7 @@ protected function setUp(): void { * Tests formatting of address. */ public function testInlineFormatterAddress(): void { - $entity = EntityTest::create([]); + $entity = EntityTest::create(); foreach ($this->addressFieldTestData() as $data) { if (!empty($data['settings'])) { $this->alterDisplaySettings($data['settings']); @@ -46,25 +57,36 @@ public function testInlineFormatterAddress(): void { } // Enable the formatter to show the icon. - $this->display->setComponent($this->fieldName, [ - 'type' => 'oe_whitelabel_helper_address_inline', - 'settings' => [ - 'show_country_flag' => TRUE, - ], - ]); - $this->display->save(); + $base_settings = [ + 'show_country_flag' => TRUE, + ]; + $this->alterDisplaySettings($base_settings); + $country_flags_folder = $this->container->get('extension.list.theme')->getPath('oe_whitelabel') . '/assets/icons/world-flags/'; $file_url_generator = $this->container->get('file_url_generator'); $country_repository = $this->container->get('address.country_repository'); - foreach ($this->addressFieldTestData() as $data) { - $entity->set($this->fieldName, $data['address']); - $this->renderEntityFields($entity, $this->display); + foreach ($this->addressFieldTestData() as $scenario => $data) { + try { + if (!empty($data['settings'])) { + $this->alterDisplaySettings(array_merge($base_settings, $data['settings'])); + } - $country_code = strtolower($data['address']['country_code']); - $country_flag_path = $file_url_generator->generateString($country_flags_folder . $country_code . '.svg'); - $country_flag_html = sprintf('%s', $country_repository->get($country_code)->getName(), $country_flag_path); - $this->assertRaw($country_flag_html . ' ' . $data['expected']); + $entity->set($this->fieldName, $data['address']); + $this->renderEntityFields($entity, $this->display); + + $country_code = strtolower($data['address']['country_code']); + $country_flag_path = $file_url_generator->generateString($country_flags_folder . $country_code . '.svg'); + $country_flag_html = sprintf( + '%s', + $country_repository->get($country_code)->getName(), + $country_flag_path + ); + $this->assertRaw($country_flag_html . ' ' . $data['expected']); + } + catch (\Exception $exception) { + throw new \Exception(sprintf('Failure on scenario %s.', $scenario), 0, $exception); + } } } From 93bb76411327191ad16be1a7feb297b063c2bc77 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 1 Aug 2023 18:23:12 +0200 Subject: [PATCH 10/16] OEL-1657: Module is required by one of the block instances. --- tests/src/Kernel/AbstractKernelTestBase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/src/Kernel/AbstractKernelTestBase.php b/tests/src/Kernel/AbstractKernelTestBase.php index c994765e3..c896dfb1e 100644 --- a/tests/src/Kernel/AbstractKernelTestBase.php +++ b/tests/src/Kernel/AbstractKernelTestBase.php @@ -17,6 +17,7 @@ abstract class AbstractKernelTestBase extends BootstrapKernelTestBase { protected static $modules = [ 'daterange_compact', 'oe_whitelabel_helper', + 'oe_corporate_blocks', ]; /** From f900e88ebb1475c0b9946dc55a0b8a84f0904ad3 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Tue, 1 Aug 2023 18:24:02 +0200 Subject: [PATCH 11/16] OEL-1657: Correct markup is now returned due to complete installation of ui_pattern dependencies. --- tests/src/Kernel/AuthenticationBlockTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/AuthenticationBlockTest.php b/tests/src/Kernel/AuthenticationBlockTest.php index 7790e36f9..14fbdc8af 100644 --- a/tests/src/Kernel/AuthenticationBlockTest.php +++ b/tests/src/Kernel/AuthenticationBlockTest.php @@ -37,7 +37,7 @@ public function testBlockRendering(): void { $actual = $crawler->filter('.oe-authentication'); $this->assertCount(1, $actual); $icon = $actual->filter('svg'); - $this->assertSame('ms-2-5 bi icon--xs', $icon->attr('class')); + $this->assertSame('me-2-5 bi icon--xs', $icon->attr('class')); $use = $icon->filter('use'); $expected = '/themes/contrib/oe_bootstrap_theme/assets/icons/bcl-default-icons.svg#person-fill'; $this->assertSame($expected, $use->attr('xlink:href')); From 94e1eff52d64425f245d1906bc192ded012682f9 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 2 Aug 2023 14:50:01 +0200 Subject: [PATCH 12/16] OEL-1657: Prefer anonymous user with additional permission over uid 1. --- .../tests/src/Kernel/SearchBlockTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php b/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php index 34e0c37bf..a7f2d0e06 100644 --- a/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php +++ b/modules/oe_whitelabel_search/tests/src/Kernel/SearchBlockTest.php @@ -7,6 +7,8 @@ use Drupal\search_api_autocomplete\Entity\Search; use Drupal\Tests\oe_whitelabel\Kernel\AbstractKernelTestBase; use Drupal\Tests\user\Traits\UserCreationTrait; +use Drupal\user\Entity\Role; +use Drupal\user\RoleInterface; use Symfony\Component\DomCrawler\Crawler; /** @@ -65,8 +67,9 @@ protected function setUp(): void { ], ])->save(); - // Add user with permissions for the autocomplete feature. - $this->setUpCurrentUser(['uid' => 1]); + Role::load(RoleInterface::ANONYMOUS_ID) + ->grantPermission('use search_api_autocomplete for search_api_autocomplete_test_view') + ->save(); } /** From 4a0f0899e778445734b6b5d0eef67d03ee1c0260 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 2 Aug 2023 17:56:49 +0200 Subject: [PATCH 13/16] OEL-1657: Fix test setup. --- tests/src/Kernel/ContentLanguageSwitcherTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/src/Kernel/ContentLanguageSwitcherTest.php b/tests/src/Kernel/ContentLanguageSwitcherTest.php index bdec322d2..dbe3a2611 100644 --- a/tests/src/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -5,7 +5,8 @@ namespace Drupal\Tests\oe_whitelabel\Kernel; use Drupal\node\Entity\Node; -use Drupal\user\Entity\User; +use Drupal\user\Entity\Role; +use Drupal\user\RoleInterface; use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\HttpFoundation\Request; @@ -47,14 +48,15 @@ protected function setUp(): void { 'language', 'locale', 'oe_multilingual', - 'oe_whitelabel_helper', - 'system', ]); $this->container->get('module_handler')->loadInclude('oe_multilingual', 'install'); oe_multilingual_install(FALSE); - \Drupal::currentUser()->setAccount(User::load(1)); + Role::load(RoleInterface::ANONYMOUS_ID) + ->grantPermission('access content') + ->save(); + // Container rebuild is needed to regenerate routes. \Drupal::service('kernel')->rebuildContainer(); } From f6b57cd79f99df5f48b8f184f9e6fd85332daa9c Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Wed, 2 Aug 2023 17:57:08 +0200 Subject: [PATCH 14/16] OEL-1657: Wrong base class. --- .../tests/src/Kernel/Paragraphs/CarouselTest.php | 2 -- .../tests/src/Kernel/Paragraphs/ParagraphsTestBase.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/CarouselTest.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/CarouselTest.php index d7e6e07a0..5d596c83e 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/CarouselTest.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/CarouselTest.php @@ -23,7 +23,6 @@ class CarouselTest extends ParagraphsTestBase { 'language', 'media_avportal', 'media_avportal_mock', - 'node', 'oe_media_avportal', 'oe_paragraphs_carousel', 'oe_whitelabel_paragraphs', @@ -41,7 +40,6 @@ protected function setUp(): void { $this->installConfig([ 'content_translation', 'media', - 'language', 'media_avportal', 'oe_media', 'oe_media_avportal', diff --git a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php index d835f74af..7529c6039 100644 --- a/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php +++ b/modules/oe_whitelabel_paragraphs/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php @@ -5,7 +5,7 @@ namespace Drupal\Tests\oe_whitelabel_paragraphs\Kernel\Paragraphs; use Drupal\paragraphs\ParagraphInterface; -use Drupal\Tests\oe_bootstrap_theme\Kernel\AbstractKernelTestBase; +use Drupal\Tests\oe_whitelabel\Kernel\AbstractKernelTestBase; /** * Base class for paragraphs tests. From aa0d3698b4114bc64ae5f200967c11fd853c59c5 Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 3 Aug 2023 14:57:41 +0200 Subject: [PATCH 15/16] OEL-1657: Re-export configurations. --- ...tion.oe_cx_project_stakeholder.default.yml | 2 ++ ...oe_organisation.oe_stakeholder.default.yml | 31 ++++++++++--------- ...ity_view_display.node.oe_sc_event.full.yml | 1 + 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml index b0f10440a..59cd08182 100644 --- a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml +++ b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_cx_project_stakeholder.default.yml @@ -51,6 +51,7 @@ content: label: hidden settings: delimiter: ', ' + properties: { } show_country_flag: true third_party_settings: { } weight: 2 @@ -72,4 +73,5 @@ hidden: oe_contact_url: true oe_logo: true oe_website: true + search_api_excerpt: true status: true diff --git a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml index e2ddfc164..e05e17e01 100644 --- a/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml +++ b/modules/oe_whitelabel_extra_project/config/overrides/core.entity_view_display.oe_organisation.oe_stakeholder.default.yml @@ -17,40 +17,40 @@ bundle: oe_stakeholder mode: default content: created: - label: hidden type: timestamp - weight: 0 - region: content + label: hidden settings: date_format: medium custom_date_format: '' timezone: '' third_party_settings: { } + weight: 0 + region: content name: - label: hidden type: string - weight: -5 - region: content + label: hidden settings: link_to_entity: false third_party_settings: { } + weight: -5 + region: content oe_acronym: - weight: 1 + type: string label: above settings: link_to_entity: false third_party_settings: { } - type: string + weight: 1 region: content oe_address: - weight: 3 + type: address_default label: above settings: { } third_party_settings: { } - type: address_default + weight: 3 region: content oe_contact_url: - weight: 5 + type: link label: above settings: trim_length: 80 @@ -59,19 +59,19 @@ content: rel: '' target: '' third_party_settings: { } - type: link + weight: 5 region: content oe_logo: type: entity_reference_entity_view - weight: 2 label: above settings: view_mode: default link: false third_party_settings: { } + weight: 2 region: content oe_website: - weight: 4 + type: link label: above settings: trim_length: 80 @@ -80,8 +80,9 @@ content: rel: '' target: '' third_party_settings: { } - type: link + weight: 4 region: content hidden: langcode: true + search_api_excerpt: true status: true diff --git a/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml b/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml index 6cc4a865d..bc63cbd70 100644 --- a/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml +++ b/modules/oe_whitelabel_starter_event/config/install/core.entity_view_display.node.oe_sc_event.full.yml @@ -55,6 +55,7 @@ content: label: inline settings: delimiter: ', ' + properties: { } show_country_flag: true third_party_settings: { } weight: 2 From 6ef4beb0c852c2124043bbee587a559f604a851d Mon Sep 17 00:00:00 2001 From: Francesco Sardara Date: Thu, 3 Aug 2023 14:58:29 +0200 Subject: [PATCH 16/16] OEL-1657: Align flag vertically. --- .../templates/oe-whitelabel-helper-address-inline.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig index 1b29e262b..192987c3e 100644 --- a/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig +++ b/modules/oe_whitelabel_helper/templates/oe-whitelabel-helper-address-inline.html.twig @@ -12,6 +12,6 @@ * @ingroup themeable */ #} - + {{ country_flag }} {{ address_items|join(address_delimiter) }}