From bf5c439f0e698bfdb6319d3b00afad122d7ea356 Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 8 Jul 2021 11:07:29 +0200 Subject: [PATCH 01/28] OEL-60: Drupal 9 Compatibility fixes. --- README.md | 2 +- behat.yml.dist | 4 +- composer.json | 68 ++++++++-------- .../oe_theme_contact_forms.info.yml | 2 +- .../oe_theme_content_call_proposals.info.yml | 2 +- .../oe_theme_content_call_tenders.info.yml | 2 +- .../oe_theme_content_consultation.info.yml | 2 +- .../oe_theme_content_entity_contact.info.yml | 2 +- ...theme_content_entity_organisation.info.yml | 2 +- .../oe_theme_content_entity_venue.info.yml | 2 +- .../oe_theme_content_event.info.yml | 2 +- .../oe_theme_content_news.info.yml | 2 +- .../oe_theme_content_organisation.info.yml | 2 +- ...me_content_organisation_reference.info.yml | 2 +- .../oe_theme_content_page.info.yml | 2 +- .../oe_theme_content_person.info.yml | 2 +- .../oe_theme_content_policy.info.yml | 2 +- .../oe_theme_content_project.info.yml | 2 +- .../oe_theme_content_publication.info.yml | 2 +- ...ent_sub_entity_document_reference.info.yml | 2 +- modules/oe_theme_demo/oe_theme_demo.info.yml | 2 +- .../oe_theme_helper/oe_theme_helper.info.yml | 2 +- .../src/TwigExtension/TwigExtension.php | 42 +++++----- .../oe_theme_inpage_navigation_test.info.yml | 2 +- .../page_header_metadata_test.info.yml | 2 +- .../Functional/NodeViewRoutesMetadataTest.php | 7 +- .../src/Functional/PageHeaderBlockTest.php | 7 +- .../field_group/InPageNavigationTest.php | 33 ++++---- .../field_group/PatternFormatterTest.php | 7 +- .../src/Functional/RetinaScaleEffectTest.php | 53 +++++++++---- .../InPageNavigationBlockTest.php | 9 ++- .../InPageNavigationLibraryTest.php | 4 +- .../MediaGalleryFormatterTest.php | 20 ++--- .../MediaThumbnailUrlFormatterTestBase.php | 2 +- .../SocialMediaLinksFormatterTestBase.php | 2 +- .../tests/src/Kernel/TwigExtensionTest.php | 8 +- .../tests/src/Unit/TwigExtensionTest.php | 11 ++- .../oe_theme_list_pages.info.yml | 2 +- .../oe_theme_paragraphs_contact.info.yml | 2 +- modules/oe_theme_test/oe_theme_test.info.yml | 2 +- oe_theme.info.yml | 2 +- oe_theme.theme | 21 +++-- phpunit.xml.dist | 10 +-- tests/Behat/OeThemeTestContext.php | 2 +- tests/EnsurePHPUnitBatchingTestListener.php | 9 +-- tests/Functional/BreadcrumbTest.php | 6 ++ tests/Functional/ConfigurationTest.php | 13 +++- .../ContentCallForProposalsRenderTest.php | 6 ++ .../ContentCallForTendersRenderTest.php | 5 ++ .../ContentConsultationRenderTest.php | 11 ++- tests/Functional/ContentEventRenderTest.php | 5 ++ tests/Functional/ContentNewsRenderTest.php | 7 +- .../ContentOrganisationRenderTest.php | 11 ++- tests/Functional/ContentPersonRenderTest.php | 15 ++-- tests/Functional/ContentProjectRenderTest.php | 13 +++- .../ContentPublicationRenderTest.php | 9 ++- tests/Functional/ContentRenderTestBase.php | 19 +++-- .../Functional/CorporateFooterRenderTest.php | 7 +- tests/Functional/ParagraphsTest.php | 9 ++- .../JavascriptBehavioursTest.php | 11 ++- tests/Kernel/AbstractKernelTestBase.php | 4 +- tests/Kernel/BlockTest.php | 6 +- tests/Kernel/BreadcrumbTest.php | 4 +- tests/Kernel/CallForProposalsRenderTest.php | 2 +- tests/Kernel/CallForTendersRenderTest.php | 2 +- tests/Kernel/ConsultationRenderTest.php | 2 +- tests/Kernel/ContactFormRenderTest.php | 6 +- tests/Kernel/ContactRenderTest.php | 4 +- tests/Kernel/ContentLanguageSwitcherTest.php | 2 +- tests/Kernel/ContentRenderTestBase.php | 6 +- tests/Kernel/EventRenderTest.php | 2 +- tests/Kernel/LanguageSwitcherTest.php | 2 +- tests/Kernel/LegacyContentRenderTest.php | 16 ++-- tests/Kernel/MainMenuTest.php | 2 +- tests/Kernel/MediaRenderTest.php | 2 +- tests/Kernel/MenuLocalTasksTest.php | 1 - .../MultilingualAbstractKernelTestBase.php | 2 +- tests/Kernel/NewsRenderTest.php | 2 +- tests/Kernel/OrganisationRenderTest.php | 2 +- tests/Kernel/PagerTest.php | 58 +++++++------- .../Paragraphs/ContactParagraphTest.php | 4 +- tests/Kernel/Paragraphs/ContentRowTest.php | 34 ++++---- .../Kernel/Paragraphs/MediaParagraphsTest.php | 78 +++++++++---------- tests/Kernel/Paragraphs/ParagraphsTest.php | 6 +- .../Kernel/Paragraphs/ParagraphsTestBase.php | 2 +- .../Paragraphs/SocialMediaFollowTest.php | 28 +++---- .../Paragraphs/TimelineParagraphTest.php | 2 +- .../Patterns/FilePatternRenderingTest.php | 2 +- tests/Kernel/PersonRenderTest.php | 4 +- .../CurrentComponentLibraryConditionTest.php | 6 +- .../CurrentEclBrandingConditionTest.php | 6 +- tests/Kernel/ProjectRenderTest.php | 2 +- tests/Kernel/RenderingTest.php | 2 +- tests/Kernel/StatusMessagesTest.php | 2 +- tests/Kernel/TimelineTest.php | 6 +- .../Kernel/ValueObject/DateTimeRangeTest.php | 2 +- tests/Kernel/ValueObject/DateTimeTest.php | 2 +- tests/Kernel/ValueObject/DateTimeTestBase.php | 4 +- tests/Kernel/ValueObject/ImageTest.php | 7 +- tests/Kernel/Webtools/SocialShareTest.php | 2 +- tests/PatternAssertions/BasePatternAssert.php | 5 +- .../PatternAssertions/FeaturedItemAssert.php | 4 +- tests/PatternAssertions/FileAssert.php | 2 +- tests/PatternAssertions/IconsTextAssert.php | 2 +- tests/PatternAssertions/ListItemAssert.php | 4 +- .../SocialMediaLinksAssert.php | 4 +- tests/Traits/RenderTrait.php | 2 +- .../Unit/ValueObject/ImageValueObjectTest.php | 4 +- .../oe_theme_js_test.info.yml | 2 +- .../oe_theme_patterns_render_test.info.yml | 2 +- 110 files changed, 506 insertions(+), 371 deletions(-) diff --git a/README.md b/README.md index 002540dea..9fd5cbf65 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build Status](https://drone.fpfis.eu/api/badges/openeuropa/oe_theme/status.svg?branch=master)](https://drone.fpfis.eu/openeuropa/oe_theme) [![Packagist](https://img.shields.io/packagist/v/openeuropa/oe_theme.svg)](https://packagist.org/packages/openeuropa/oe_theme) -Drupal 8 theme based on the [Europa Component Library][1] (ECL). +Drupal 8 and 9 theme based on the [Europa Component Library][1] (ECL). **Table of contents:** diff --git a/behat.yml.dist b/behat.yml.dist index 5263eaf97..94fafa961 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -2,7 +2,7 @@ default: suites: default: paths: - - %paths.base%/tests/features + - "%paths.base%/tests/features" contexts: - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\MarkupContext @@ -94,6 +94,6 @@ default: project funding header: "#project-funding .ecl-u-type-heading-2" FriendsOfBehat\ServiceContainerExtension: imports: - - 'build/modules/contrib/oe_content/tests/Behat/config/services.yml' + - 'build/modules/contrib/oe_content/tests/src/Behat/config/services.yml' formatters: progress: ~ diff --git a/composer.json b/composer.json index 9eb857a2c..b9bf9a651 100644 --- a/composer.json +++ b/composer.json @@ -7,63 +7,65 @@ "prefer-stable": true, "require": { "php": ">=7.3", - "drupal/core": "^8.9.14", - "drupal/smart_trim": "^1.2", + "drupal/core": "^8.9.16 ||^9.1", + "drupal/smart_trim": "^1.3", "drupal/twig_field_value": "^2.0", - "drupal/ui_patterns": "^1.0", - "openeuropa/ecl-twig-loader": "^3.0", - "openeuropa/oe_time_caching": "~1.0", + "drupal/ui_patterns": "^1.2", + "openeuropa/ecl-twig-loader": "3.x-dev", + "openeuropa/oe_time_caching": "dev-master", "ralouphie/mimey": "^2.1" }, "require-dev": { - "composer/installers": "~1.5", - "consolidation/annotated-command": "^2.8.2", + "composer/installers": "~1.11", + "consolidation/annotated-command": "^2.12", "consolidation/robo": "~1.4", - "cweagans/composer-patches": "~1.6.7", - "drupal/core-composer-scaffold": "^8.8", + "cweagans/composer-patches": "~1.7.1", + "drupal/core-composer-scaffold": "^8.9 || ^9.1", "drupal/address": "~1.9", - "drupal/composite_reference": "~1.0-alpha1", - "drupal/config_devel": "~1.2", + "drupal/composite_reference": "~1.0-alpha2", + "drupal/config_devel": "~1.8", "drupal/datetime_testing": "1.x-dev", "drupal/description_list_field": "1.0.x-dev", "drupal/drupal-driver": "^2.1.1", - "drupal/drupal-extension": "~4.0", + "drupal/drupal-extension": "~4.1", "drupal/emr": "~1.0-beta9", - "drupal/entity_reference_revisions": "~1.3", - "drupal/entity_browser": "^2.5", - "drupal/extra_field": "^1.1", - "drupal/field_group": "~3.0", + "drupal/entity_reference_revisions": "~1.9", + "drupal/entity_browser": "^2.6", + "drupal/extra_field": "^1.3", + "drupal/field_group": "^3.1", "drupal/inline_entity_form": "~1.0-rc9", - "drupal/json_field": "^1.0.0-rc2", + "drupal/json_field": "^1.0.0-rc4", "drupal/renderviz": "^1.0@alpha", - "drupal/styleguide": "~1.0-alpha3", + "drupal/styleguide": "~1.0@beta", "drupal/typed_link": "~1.1", - "drush/drush": "~9.0", + "drush/drush": "~10.3", "easyrdf/easyrdf": "1.0.0 as 0.9.1", "friends-of-behat/service-container-extension": "^1.0", - "guzzlehttp/guzzle": "~6.3", "instaclick/php-webdriver": "^1.4.7", "nikic/php-parser": "~3.0", "openeuropa/behat-transformation-context": "~0.1", - "openeuropa/code-review": "~1.5", - "openeuropa/drupal-core-require-dev": "^8.9.14", - "openeuropa/oe_content": "2.x-dev", - "openeuropa/oe_corporate_blocks": "~4.0", + "openeuropa/code-review": "~1.6", + "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", + "openeuropa/oe_content": "dev-EWPP-911", + "openeuropa/oe_corporate_blocks": "~4.1", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", - "openeuropa/oe_paragraphs": "dev-master", - "openeuropa/oe_search": "~1.0", - "openeuropa/oe_webtools": "~1.10", - "openeuropa/oe_contact_forms": "~1.0", + "openeuropa/oe_paragraphs": "dev-OEL-67", + "openeuropa/oe_search": "dev-OEL-60", + "openeuropa/oe_webtools": "~1.12", + "openeuropa/oe_contact_forms": "dev-OEL-164", "openeuropa/rdf_skos": "~1.0", - "openeuropa/task-runner-drupal-project-symlink": "^1.0", - "phpunit/phpunit": "~6.0", - "symfony/dom-crawler": "~3.4" + "openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta3", + "phpspec/prophecy-phpunit": "^1 || ^2", + "symfony/dom-crawler": "~4.4" }, "_readme": [ "We explicitly require consolidation/robo to allow lower 'composer update --prefer-lowest' to complete successfully.", - "We explicitly require consolidation/annotated-command to allow lower 'composer update --prefer-lowest' to complete successfully." + "We explicitly require consolidation/annotated-command to allow lower 'composer update --prefer-lowest' to complete successfully.", + "openeuropa/oe_search is used from a branch because of major upgrading is pending. Change again when it released.", + "openeuropa/ecl-twig-loader is used from a branch because it must be upgrade to be D9 compatible. Change again when it released.", + "openeuropa/oe_multilingual is used from a branch because it was an issue with D9. Change again when it released." ], "conflict": { "openeuropa/oe_corporate_blocks": "<3.0.0", @@ -81,7 +83,7 @@ "autoload-dev": { "psr-4": { "Drupal\\Tests\\oe_theme\\": "./tests/", - "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/", + "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/src/", "Drupal\\Tests\\oe_media\\": "./build/modules/contrib/oe_media/tests/src/" } }, diff --git a/modules/oe_theme_contact_forms/oe_theme_contact_forms.info.yml b/modules/oe_theme_contact_forms/oe_theme_contact_forms.info.yml index 064891c5d..56efb3311 100644 --- a/modules/oe_theme_contact_forms/oe_theme_contact_forms.info.yml +++ b/modules/oe_theme_contact_forms/oe_theme_contact_forms.info.yml @@ -2,6 +2,6 @@ name: OpenEuropa Theme Contact Forms type: module description: Companion module for the OE Contact Forms module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_contact_forms:oe_contact_forms diff --git a/modules/oe_theme_content_call_proposals/oe_theme_content_call_proposals.info.yml b/modules/oe_theme_content_call_proposals/oe_theme_content_call_proposals.info.yml index 467f9ff3e..0ca4da7d6 100644 --- a/modules/oe_theme_content_call_proposals/oe_theme_content_call_proposals.info.yml +++ b/modules/oe_theme_content_call_proposals/oe_theme_content_call_proposals.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Call for proposals Content type: module description: Companion module for the OE Call for proposals Content module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - field_group:field_group diff --git a/modules/oe_theme_content_call_tenders/oe_theme_content_call_tenders.info.yml b/modules/oe_theme_content_call_tenders/oe_theme_content_call_tenders.info.yml index 495913361..f25a37195 100644 --- a/modules/oe_theme_content_call_tenders/oe_theme_content_call_tenders.info.yml +++ b/modules/oe_theme_content_call_tenders/oe_theme_content_call_tenders.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Call for tenders Content type: module description: Companion module for the OE Call for tenders content module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - field_group:field_group diff --git a/modules/oe_theme_content_consultation/oe_theme_content_consultation.info.yml b/modules/oe_theme_content_consultation/oe_theme_content_consultation.info.yml index 53897c97d..1a5ee251c 100644 --- a/modules/oe_theme_content_consultation/oe_theme_content_consultation.info.yml +++ b/modules/oe_theme_content_consultation/oe_theme_content_consultation.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Consultation Content type: module description: Companion module for the OE Content Consultation module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - drupal:datetime diff --git a/modules/oe_theme_content_entity_contact/oe_theme_content_entity_contact.info.yml b/modules/oe_theme_content_entity_contact/oe_theme_content_entity_contact.info.yml index e68732134..71c0c8c46 100755 --- a/modules/oe_theme_content_entity_contact/oe_theme_content_entity_contact.info.yml +++ b/modules/oe_theme_content_entity_contact/oe_theme_content_entity_contact.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Content Entity Contact description: Companion module for the OE Content Entity Contact module package: OpenEuropa type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_theme:oe_theme_helper diff --git a/modules/oe_theme_content_entity_organisation/oe_theme_content_entity_organisation.info.yml b/modules/oe_theme_content_entity_organisation/oe_theme_content_entity_organisation.info.yml index c841cbefc..7da2c78aa 100644 --- a/modules/oe_theme_content_entity_organisation/oe_theme_content_entity_organisation.info.yml +++ b/modules/oe_theme_content_entity_organisation/oe_theme_content_entity_organisation.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Content Entity Organisation description: Companion module for the OE Content Entity Organisation module package: OpenEuropa type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_theme:oe_theme_helper diff --git a/modules/oe_theme_content_entity_venue/oe_theme_content_entity_venue.info.yml b/modules/oe_theme_content_entity_venue/oe_theme_content_entity_venue.info.yml index 3aa0ad1e0..74e6733b8 100755 --- a/modules/oe_theme_content_entity_venue/oe_theme_content_entity_venue.info.yml +++ b/modules/oe_theme_content_entity_venue/oe_theme_content_entity_venue.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Content Entity Venue description: Companion module for the OE Content Entity Venue module package: OpenEuropa type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_theme:oe_theme_helper diff --git a/modules/oe_theme_content_event/oe_theme_content_event.info.yml b/modules/oe_theme_content_event/oe_theme_content_event.info.yml index 6adacbce2..6e394d01c 100644 --- a/modules/oe_theme_content_event/oe_theme_content_event.info.yml +++ b/modules/oe_theme_content_event/oe_theme_content_event.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Event Content type: module description: Companion module for the OE Content Event module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - oe_content:oe_content_event diff --git a/modules/oe_theme_content_news/oe_theme_content_news.info.yml b/modules/oe_theme_content_news/oe_theme_content_news.info.yml index 01690228c..0c7fa100f 100644 --- a/modules/oe_theme_content_news/oe_theme_content_news.info.yml +++ b/modules/oe_theme_content_news/oe_theme_content_news.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme News Content type: module description: Companion module for the OE Content News module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - oe_content_news:oe_content_news diff --git a/modules/oe_theme_content_organisation/oe_theme_content_organisation.info.yml b/modules/oe_theme_content_organisation/oe_theme_content_organisation.info.yml index 5e84d35f9..8efb3489a 100644 --- a/modules/oe_theme_content_organisation/oe_theme_content_organisation.info.yml +++ b/modules/oe_theme_content_organisation/oe_theme_content_organisation.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Organisation Content type: module description: Companion module for the OE Organisation Content module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_content:oe_content_organisation - oe_content:oe_content_organisation_person_reference diff --git a/modules/oe_theme_content_organisation_reference/oe_theme_content_organisation_reference.info.yml b/modules/oe_theme_content_organisation_reference/oe_theme_content_organisation_reference.info.yml index 81022fd3c..a1f18a5af 100644 --- a/modules/oe_theme_content_organisation_reference/oe_theme_content_organisation_reference.info.yml +++ b/modules/oe_theme_content_organisation_reference/oe_theme_content_organisation_reference.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Organisation Reference type: module description: Companion module for the OE Organisation Reference module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_content:oe_content_organisation_reference diff --git a/modules/oe_theme_content_page/oe_theme_content_page.info.yml b/modules/oe_theme_content_page/oe_theme_content_page.info.yml index b21ebc001..8f7e59f13 100644 --- a/modules/oe_theme_content_page/oe_theme_content_page.info.yml +++ b/modules/oe_theme_content_page/oe_theme_content_page.info.yml @@ -2,6 +2,6 @@ name: OpenEuropa Theme Page Content type: module description: Companion module for the OE Content Page module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_content_page:oe_content_page diff --git a/modules/oe_theme_content_person/oe_theme_content_person.info.yml b/modules/oe_theme_content_person/oe_theme_content_person.info.yml index afa1ca8c1..54068ac4f 100644 --- a/modules/oe_theme_content_person/oe_theme_content_person.info.yml +++ b/modules/oe_theme_content_person/oe_theme_content_person.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Person Content type: module description: Companion module for the OE Content Person module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field diff --git a/modules/oe_theme_content_policy/oe_theme_content_policy.info.yml b/modules/oe_theme_content_policy/oe_theme_content_policy.info.yml index 16cfc753e..91ac6ccc2 100644 --- a/modules/oe_theme_content_policy/oe_theme_content_policy.info.yml +++ b/modules/oe_theme_content_policy/oe_theme_content_policy.info.yml @@ -2,6 +2,6 @@ name: OpenEuropa Theme Policy Content type: module description: Companion module for the OE Content Policy module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_content:oe_content_policy diff --git a/modules/oe_theme_content_project/oe_theme_content_project.info.yml b/modules/oe_theme_content_project/oe_theme_content_project.info.yml index 12176c0ed..49a8a0299 100644 --- a/modules/oe_theme_content_project/oe_theme_content_project.info.yml +++ b/modules/oe_theme_content_project/oe_theme_content_project.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Project Content type: module description: Companion module for the OE Content Project module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - field_group:field_group diff --git a/modules/oe_theme_content_publication/oe_theme_content_publication.info.yml b/modules/oe_theme_content_publication/oe_theme_content_publication.info.yml index fd9c04b03..89021f364 100644 --- a/modules/oe_theme_content_publication/oe_theme_content_publication.info.yml +++ b/modules/oe_theme_content_publication/oe_theme_content_publication.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Publication Content type: module description: Companion module for the OE Content Publication module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - oe_content:oe_content_publication diff --git a/modules/oe_theme_content_sub_entity_document_reference/oe_theme_content_sub_entity_document_reference.info.yml b/modules/oe_theme_content_sub_entity_document_reference/oe_theme_content_sub_entity_document_reference.info.yml index fff13ebb6..c612e69bd 100644 --- a/modules/oe_theme_content_sub_entity_document_reference/oe_theme_content_sub_entity_document_reference.info.yml +++ b/modules/oe_theme_content_sub_entity_document_reference/oe_theme_content_sub_entity_document_reference.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Document reference type: module description: Companion module for the OE Content Entity Document reference module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_content:oe_content_sub_entity_document_reference - oe_theme:oe_theme_content_publication diff --git a/modules/oe_theme_demo/oe_theme_demo.info.yml b/modules/oe_theme_demo/oe_theme_demo.info.yml index 3a8717b9c..345199c65 100644 --- a/modules/oe_theme_demo/oe_theme_demo.info.yml +++ b/modules/oe_theme_demo/oe_theme_demo.info.yml @@ -1,7 +1,7 @@ name: OpenEuropa Theme Demo description: OpenEuropa Theme Demo type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 package: OpenEuropa dependencies: - drupal:block diff --git a/modules/oe_theme_helper/oe_theme_helper.info.yml b/modules/oe_theme_helper/oe_theme_helper.info.yml index 94b414f65..a22660015 100644 --- a/modules/oe_theme_helper/oe_theme_helper.info.yml +++ b/modules/oe_theme_helper/oe_theme_helper.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Helper type: module description: OpenEuropa theme helpers and tools. package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - drupal:node - ui_patterns:ui_patterns_library diff --git a/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php b/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php index ec5e241d7..54874f939 100644 --- a/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php +++ b/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php @@ -18,6 +18,10 @@ use Drupal\oe_theme_helper\EuropeanUnionLanguages; use Drupal\smart_trim\Truncate\TruncateHTML; use Drupal\Core\Template\TwigExtension as CoreTwigExtension; +use Twig\Environment; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; /** * Collection of extra Twig extensions as filters and functions. @@ -25,7 +29,7 @@ * We don't enforce any strict type checking on filters' arguments as they are * coming straight from Twig templates. */ -class TwigExtension extends \Twig_Extension { +class TwigExtension extends AbstractExtension { /** * The language manager. @@ -59,22 +63,16 @@ public function __construct(LanguageManagerInterface $languageManager, RendererI */ public function getFilters(): array { return [ - new \Twig_SimpleFilter('format_size', 'format_size'), - new \Twig_SimpleFilter('to_language', [$this, 'toLanguageName']), - new \Twig_SimpleFilter('to_native_language', [ - $this, - 'toNativeLanguageName', - ]), - new \Twig_SimpleFilter('to_internal_language_id', [ - $this, - 'toInternalLanguageId', - ]), - new \Twig_SimpleFilter('to_file_icon', [$this, 'toFileIcon']), - new \Twig_SimpleFilter('to_date_status', [$this, 'toDateStatus']), - new \Twig_SimpleFilter('to_ecl_attributes', [$this, 'toEclAttributes']), - new \Twig_SimpleFilter('smart_trim', [$this, 'smartTrim'], ['needs_environment' => TRUE]), - new \Twig_SimpleFilter('is_external_url', [UrlHelper::class, 'isExternal']), - new \Twig_SimpleFilter('filter_empty', [$this, 'filterEmpty']), + new TwigFilter('format_size', 'format_size'), + new TwigFilter('to_language', [$this, 'toLanguageName']), + new TwigFilter('to_native_language', [$this, 'toNativeLanguageName']), + new TwigFilter('to_internal_language_id', [$this, 'toInternalLanguageId']), + new TwigFilter('to_file_icon', [$this, 'toFileIcon']), + new TwigFilter('to_date_status', [$this, 'toDateStatus']), + new TwigFilter('to_ecl_attributes', [$this, 'toEclAttributes']), + new TwigFilter('smart_trim', [$this, 'smartTrim'], ['needs_environment' => TRUE]), + new TwigFilter('is_external_url', [UrlHelper::class, 'isExternal']), + new TwigFilter('filter_empty', [$this, 'filterEmpty']), ]; } @@ -83,9 +81,9 @@ public function getFilters(): array { */ public function getFunctions(): array { return [ - new \Twig_SimpleFunction('to_ecl_icon', [$this, 'toEclIcon'], ['needs_context' => TRUE]), - new \Twig_SimpleFunction('get_link_icon', [$this, 'getLinkIcon'], ['needs_context' => TRUE]), - new \Twig_SimpleFunction('ecl_footer_links', [$this, 'eclFooterLinks'], ['needs_context' => TRUE]), + new TwigFunction('to_ecl_icon', [$this, 'toEclIcon'], ['needs_context' => TRUE]), + new TwigFunction('get_link_icon', [$this, 'getLinkIcon'], ['needs_context' => TRUE]), + new TwigFunction('ecl_footer_links', [$this, 'eclFooterLinks'], ['needs_context' => TRUE]), ]; } @@ -546,7 +544,7 @@ public function toEclIcon(array $context, $icon, string $size = ''): array { /** * Trim given input using smart_trim module heuristics. * - * @param \Twig_Environment $env + * @param \Twig\Environment $env * Current Twig environment. * @param mixed $input * Input to be trimmed, it can be a string, an object or a render array. @@ -556,7 +554,7 @@ public function toEclIcon(array $context, $icon, string $size = ''): array { * @return mixed * The trimmed output. */ - public function smartTrim(\Twig_Environment $env, $input, $limit) { + public function smartTrim(Environment $env, $input, $limit) { // Bubbles Twig template argument's cacheability & attachment metadata. $this->bubbleArgMetadata($input); $truncate = new TruncateHTML(); diff --git a/modules/oe_theme_helper/tests/modules/oe_theme_inpage_navigation_test/oe_theme_inpage_navigation_test.info.yml b/modules/oe_theme_helper/tests/modules/oe_theme_inpage_navigation_test/oe_theme_inpage_navigation_test.info.yml index 42e562e0d..fc18cb592 100644 --- a/modules/oe_theme_helper/tests/modules/oe_theme_inpage_navigation_test/oe_theme_inpage_navigation_test.info.yml +++ b/modules/oe_theme_helper/tests/modules/oe_theme_inpage_navigation_test/oe_theme_inpage_navigation_test.info.yml @@ -2,6 +2,6 @@ name: 'OpenEuropa Theme In-page Navigation Test' type: module description: 'Module for testing in-page navigation functionality' package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_theme:oe_theme_helper diff --git a/modules/oe_theme_helper/tests/modules/page_header_metadata_test/page_header_metadata_test.info.yml b/modules/oe_theme_helper/tests/modules/page_header_metadata_test/page_header_metadata_test.info.yml index d507800cb..d4b160e8b 100644 --- a/modules/oe_theme_helper/tests/modules/page_header_metadata_test/page_header_metadata_test.info.yml +++ b/modules/oe_theme_helper/tests/modules/page_header_metadata_test/page_header_metadata_test.info.yml @@ -3,4 +3,4 @@ type: module description: 'PageHeaderMetadata test module.' package: Testing version: VERSION -core: 8.x +core_version_requirement: ^8.9 || ^9.1 diff --git a/modules/oe_theme_helper/tests/src/Functional/NodeViewRoutesMetadataTest.php b/modules/oe_theme_helper/tests/src/Functional/NodeViewRoutesMetadataTest.php index 50afe94ee..59bf4065b 100644 --- a/modules/oe_theme_helper/tests/src/Functional/NodeViewRoutesMetadataTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/NodeViewRoutesMetadataTest.php @@ -28,6 +28,11 @@ class NodeViewRoutesMetadataTest extends BrowserTestBase { 'workflows', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * A user with permission to see revisions. * @@ -38,7 +43,7 @@ class NodeViewRoutesMetadataTest extends BrowserTestBase { /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Enable oe_theme and set it as default. diff --git a/modules/oe_theme_helper/tests/src/Functional/PageHeaderBlockTest.php b/modules/oe_theme_helper/tests/src/Functional/PageHeaderBlockTest.php index bb315abfd..4ac5fa226 100644 --- a/modules/oe_theme_helper/tests/src/Functional/PageHeaderBlockTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/PageHeaderBlockTest.php @@ -29,7 +29,12 @@ class PageHeaderBlockTest extends BrowserTestBase { /** * {@inheritdoc} */ - public function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + public function setUp(): void { parent::setUp(); // Enable oe_theme and set it as default. diff --git a/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/InPageNavigationTest.php b/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/InPageNavigationTest.php index 80e64a68d..1bfa0aebd 100644 --- a/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/InPageNavigationTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/InPageNavigationTest.php @@ -47,7 +47,12 @@ class InPageNavigationTest extends BrowserTestBase { /** * {@inheritdoc} */ - public function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + public function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. @@ -174,25 +179,25 @@ public function testOutput(): void { // Assert first field group. $content_first_group = $content_items[0]->getText(); - $this->assertContains('Field label field_test_0', $content_first_group); - $this->assertContains('100', $content_first_group); - $this->assertContains('Field label field_test_1', $content_first_group); - $this->assertContains('200', $content_first_group); + $this->assertStringContainsString('Field label field_test_0', $content_first_group); + $this->assertStringContainsString('100', $content_first_group); + $this->assertStringContainsString('Field label field_test_1', $content_first_group); + $this->assertStringContainsString('200', $content_first_group); // Assert second field group. $content_second_group = $content_items[1]->getText(); - $this->assertContains('Single text', $content_second_group); - $this->assertContains('Output from SingleTextFieldTest', $content_second_group); - $this->assertContains('Aap', $content_second_group); - $this->assertContains('Noot', $content_second_group); + $this->assertStringContainsString('Single text', $content_second_group); + $this->assertStringContainsString('Output from SingleTextFieldTest', $content_second_group); + $this->assertStringContainsString('Aap', $content_second_group); + $this->assertStringContainsString('Noot', $content_second_group); // Assert third field group. $content_third_group = $content_items[2]->getText(); - $this->assertContains('Field group html_element', $content_third_group); - $this->assertContains('Field label field_test_2', $content_third_group); - $this->assertContains('300', $content_third_group); - $this->assertContains('Field label field_test_3', $content_third_group); - $this->assertContains('400', $content_third_group); + $this->assertStringContainsString('Field group html_element', $content_third_group); + $this->assertStringContainsString('Field label field_test_2', $content_third_group); + $this->assertStringContainsString('300', $content_third_group); + $this->assertStringContainsString('Field label field_test_3', $content_third_group); + $this->assertStringContainsString('400', $content_third_group); // Assert fourth field group - it mustn't exist. $this->assertSession()->elementTextNotContains('css', 'body', 'Field group inpage_nav_item_3'); diff --git a/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/PatternFormatterTest.php b/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/PatternFormatterTest.php index e4a9b2a91..453162fb0 100755 --- a/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/PatternFormatterTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/Plugin/field_group/PatternFormatterTest.php @@ -32,7 +32,12 @@ class PatternFormatterTest extends BrowserTestBase { /** * {@inheritdoc} */ - public function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + public function setUp(): void { parent::setUp(); // Enable oe_theme and set it as default. diff --git a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php index 2e06ad553..c7279a6a8 100644 --- a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php @@ -4,7 +4,8 @@ namespace Drupal\Tests\oe_theme_helper\Functional; -use Drupal\FunctionalTests\Image\ToolkitTestBase; +use Drupal\Tests\token\Kernel\KernelTestBase; +use Drupal\Tests\Traits\Core\Image\ToolkitTestTrait; /** * Tests that the Retina Scale effect upscales images appropriately. @@ -13,12 +14,25 @@ * * @group batch3 */ -class RetinaScaleEffectTest extends ToolkitTestBase { +class RetinaScaleEffectTest extends KernelTestBase { + use ToolkitTestTrait; + + /** + * Testing image. + * + * @var \Drupal\Core\Image\ImageInterface + */ + protected $image; /** * {@inheritdoc} */ - public static $modules = ['image', 'oe_theme_helper']; + public static $modules = [ + 'image', + 'oe_theme_helper', + 'image_test', + 'system', + ]; /** * The image effect manager. @@ -30,16 +44,23 @@ class RetinaScaleEffectTest extends ToolkitTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { parent::setUp(); $this->manager = $this->container->get('plugin.manager.image.effect'); + $this->image = $this->getImage(); + $this->imageTestReset(); } /** * Test the retina scale effect using a big enough image. */ public function testRetinaScaleEffect(): void { - $this->assertImageEffect('retina_image_scale', [ + $this->assertImageEffect(['scale'], 'retina_image_scale', [ // Set the desired width to be smaller than the image width. 'width' => 10, 'height' => 10, @@ -47,15 +68,15 @@ public function testRetinaScaleEffect(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEqual($calls['scale'][0][0], 10, 'Width was passed correctly'); - $this->assertEqual($calls['scale'][0][1], 10, 'Height was based off aspect ratio and passed correctly'); + $this->assertEquals(10, $calls['scale'][0][0], 'Width was passed correctly'); + $this->assertEquals(10, $calls['scale'][0][1], 'Height was based off aspect ratio and passed correctly'); } /** * Test the retina scale effect using upscaling. */ public function testScaleEffectDefaultUpscaling(): void { - $this->assertImageEffect('retina_image_scale', [ + $this->assertImageEffect(['scale'], 'retina_image_scale', [ // Set the desired width to be higher than the image width. 'width' => $this->image->getWidth() * 4, 'upscale' => TRUE, @@ -63,28 +84,28 @@ public function testScaleEffectDefaultUpscaling(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEqual($calls['scale'][0][0], $this->image->getWidth() * 4, 'Width was passed correctly'); + $this->assertEquals($this->image->getWidth() * 4, $calls['scale'][0][0], 'Width was passed correctly'); } /** * Test the retina scale effect using an image smaller than desired. */ public function testRetinaScaleEffectForcedUpscaling(): void { - $this->assertImageEffect('retina_image_scale', [ + $this->assertImageEffect(['scale'], 'retina_image_scale', [ // Set the desired width to be higher than the image width. 'width' => $this->image->getWidth() * 10, ]); $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEqual($calls['scale'][0][0], $this->image->getWidth() * 2, 'Width is double the original size.'); + $this->assertEquals($this->image->getWidth() * 2, $calls['scale'][0][0], 'Width is double the original size.'); } /** * Test the retina scale effect using a multiplier of 3. */ public function testTripleMultiplierRetinaScaleEffect(): void { - $this->assertImageEffect('retina_image_scale', [ + $this->assertImageEffect(['scale'], 'retina_image_scale', [ // Set the desired width to be higher than the image width. 'width' => $this->image->getWidth() * 10, 'multiplier' => 3, @@ -92,18 +113,22 @@ public function testTripleMultiplierRetinaScaleEffect(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEqual($calls['scale'][0][0], $this->image->getWidth() * 3, 'Width is triple the original size.'); + $this->assertEquals($this->image->getWidth() * 3, $calls['scale'][0][0], 'Width is triple the original size.'); } /** * Asserts the effect processing of an image effect plugin. * + * @param array $operations + * Array with the operations to be done. * @param string $effect_name * The name of the image effect to test. * @param array $data * The data to pass to the image effect. + * + * @throws \Drupal\Component\Plugin\Exception\PluginException */ - protected function assertImageEffect($effect_name, array $data): void { + protected function assertImageEffect(array $operations, $effect_name, array $data): void { /** @var \Drupal\image\ImageEffectInterface $effect */ $effect = $this->manager->createInstance($effect_name, ['data' => $data]); $this->assertTrue($effect->applyEffect($this->image), 'Function returned the expected value.'); diff --git a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php index ef16985ed..0e8266255 100644 --- a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php +++ b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php @@ -25,12 +25,17 @@ class InPageNavigationBlockTest extends WebDriverTestBase { /** * {@inheritdoc} */ - public function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + public function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by diff --git a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php index 705ff2edb..e37418540 100644 --- a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php +++ b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php @@ -33,12 +33,12 @@ class InPageNavigationLibraryTest extends WebDriverTestBase { /** * {@inheritdoc} */ - public function setUp() { + public function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by diff --git a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php index e2d643291..90a3647a6 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php @@ -46,7 +46,7 @@ class MediaGalleryFormatterTest extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('entity_test'); $this->installEntitySchema('media'); @@ -210,7 +210,7 @@ public function testFormatter(): void { $this->assertEquals('Alt text for test image.', $image_node->attr('alt')); $this->assertStringEndsWith('/example_1.jpeg', $image_node->attr('src')); $caption = $items->first()->filter('.ecl-gallery__description'); - $this->assertContains('Extra image title', $caption->html()); + $this->assertStringContainsString('Extra image title', $caption->html()); $this->assertEmpty($caption->filter('.ecl-gallery__meta')->html()); // Test the second gallery item. @@ -222,7 +222,7 @@ public function testFormatter(): void { $this->assertEquals("Energy, let's save it!", $image_node->attr('alt')); $this->assertStringEndsWith('/oembed_thumbnails/LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg', $image_node->attr('src')); $caption = $items->eq(1)->filter('.ecl-gallery__description'); - $this->assertContains($video_media->label(), $caption->html()); + $this->assertStringContainsString($video_media->label(), $caption->html()); $this->assertEmpty($caption->filter('.ecl-gallery__meta')->html()); // Test the third item. @@ -234,7 +234,7 @@ public function testFormatter(): void { $this->assertEquals('Alt text for test video iframe.', $image_node->attr('alt')); $this->assertStringEndsWith('/placeholder.png', $image_node->attr('src')); $caption = $items->eq(2)->filter('.ecl-gallery__description'); - $this->assertContains('Test video iframe title', $caption->html()); + $this->assertStringContainsString('Test video iframe title', $caption->html()); $this->assertEmpty($caption->filter('.ecl-gallery__meta')->html()); // Test that all the cache tags have present and bubbled up. @@ -271,14 +271,14 @@ public function testFormatter(): void { // Test the contents of the first item. $caption = $items->first()->filter('.ecl-gallery__description'); - $this->assertContains($image_media->label(), $caption->html()); + $this->assertStringContainsString($image_media->label(), $caption->html()); $copyright = $caption->filter('.ecl-gallery__meta'); $this->assertCount(1, $copyright); $this->assertEquals('Copyright for test image ©', $copyright->html()); // Test the second gallery item. $caption = $items->eq(1)->filter('.ecl-gallery__description'); - $this->assertContains($video_media->label(), $caption->html()); + $this->assertStringContainsString($video_media->label(), $caption->html()); $copyright = $caption->filter('.ecl-gallery__meta'); $this->assertCount(1, $copyright); $this->assertEquals('Copyright for test remote video ©', $copyright->html()); @@ -305,9 +305,9 @@ public function testFormatter(): void { // Test the contents of the first item. $image_node = $items->first()->filter('img'); $this->assertEquals('Alt text for test image.', $image_node->attr('alt')); - $this->assertContains('/files/styles/medium/public/example_1.jpeg?itok=', $image_node->attr('src')); + $this->assertStringContainsString('/files/styles/medium/public/example_1.jpeg?itok=', $image_node->attr('src')); $caption = $items->first()->filter('.ecl-gallery__description'); - $this->assertContains($image_media->label(), $caption->html()); + $this->assertStringContainsString($image_media->label(), $caption->html()); // Test the second gallery item. $this->assertStringStartsWith( @@ -316,12 +316,12 @@ public function testFormatter(): void { ); $image_node = $items->eq(1)->filter('img'); $this->assertEquals("Energy, let's save it!", $image_node->attr('alt')); - $this->assertContains( + $this->assertStringContainsString( '/files/styles/medium/public/oembed_thumbnails/LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg?itok=', $image_node->attr('src') ); $caption = $items->eq(1)->filter('.ecl-gallery__description'); - $this->assertContains($video_media->label(), $caption->html()); + $this->assertStringContainsString($video_media->label(), $caption->html()); $this->assertEmpty($caption->filter('.ecl-gallery__meta')->html()); } diff --git a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaThumbnailUrlFormatterTestBase.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaThumbnailUrlFormatterTestBase.php index 471ffd9a0..bca6e26cc 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaThumbnailUrlFormatterTestBase.php +++ b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaThumbnailUrlFormatterTestBase.php @@ -32,7 +32,7 @@ class MediaThumbnailUrlFormatterTestBase extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('entity_test'); $this->installEntitySchema('media'); diff --git a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/SocialMediaLinksFormatterTestBase.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/SocialMediaLinksFormatterTestBase.php index 79d362c6f..c17d35e54 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/SocialMediaLinksFormatterTestBase.php +++ b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/SocialMediaLinksFormatterTestBase.php @@ -31,7 +31,7 @@ class SocialMediaLinksFormatterTestBase extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('entity_test'); } diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index 1a094ef11..6e7c73f54 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php @@ -54,10 +54,10 @@ public function testSmartTrimFilter(array $variables, array $assertions, array $ if ($metadata) { /** @var \Drupal\Core\Render\BubbleableMetadata $actual_metadata */ $actual_metadata = $context->pop(); - $this->assertEqual($actual_metadata->getAttachments(), $metadata['attachments']); - $this->assertEqual($actual_metadata->getCacheContexts(), $metadata['contexts']); - $this->assertEqual($actual_metadata->getCacheTags(), $metadata['tags']); - $this->assertEqual($actual_metadata->getCacheMaxAge(), $metadata['max_age']); + $this->assertEquals($metadata['attachments'], $actual_metadata->getAttachments()); + $this->assertEquals($metadata['contexts'], $actual_metadata->getCacheContexts()); + $this->assertEquals($metadata['tags'], $actual_metadata->getCacheTags()); + $this->assertEquals($metadata['max_age'], $actual_metadata->getCacheMaxAge()); } $this->assertRendering($output, $assertions); diff --git a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php index ddd3934df..672a71c2d 100644 --- a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php @@ -9,7 +9,10 @@ use Drupal\Core\Render\Renderer; use Drupal\Core\Template\Loader\StringLoader; use Drupal\oe_theme_helper\TwigExtension\TwigExtension; +use Drupal\oe_theme_helper\EuropeanUnionLanguages; use Drupal\Tests\UnitTestCase; +use Twig\Environment; +use Twig\Error\RuntimeError; /** * Tests for the custom Twig filters and functions extension. @@ -53,7 +56,7 @@ class TwigExtensionTest extends UnitTestCase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // It is expected that some filters will request the list of languages. In @@ -81,7 +84,7 @@ protected function setUp() { // For convenience, make a version of the Twig environment available that // has the tested extension preloaded. $loader = new StringLoader(); - $this->twig = new \Twig_Environment($loader); + $this->twig = new Environment($loader); $this->twig->addExtension($this->extension); } @@ -213,7 +216,7 @@ public function testPassingInvalidLanguageCodesToNativeLanguageName($invalid_lan $this->twig->render("{{ '$invalid_language_code'|to_native_language }}"); $this->fail('The expected exception was not thrown.'); } - catch (\Twig_Error_Runtime $e) { + catch (RuntimeError $e) { // Twig wraps any exception that occurs during rendering with its own // runtime exception. Rethrow the original exception so we can verify that // the correct one is being thrown. @@ -256,7 +259,7 @@ public function invalidLanguageCodesProvider(): array { * names as values. */ protected static function getEuropeanUnionLanguageList(): array { - return TwigExtension::getEuropeanUnionLanguageList(); + return EuropeanUnionLanguages::getLanguageList(); } /** diff --git a/modules/oe_theme_list_pages/oe_theme_list_pages.info.yml b/modules/oe_theme_list_pages/oe_theme_list_pages.info.yml index 16f10cb4d..565b378b1 100644 --- a/modules/oe_theme_list_pages/oe_theme_list_pages.info.yml +++ b/modules/oe_theme_list_pages/oe_theme_list_pages.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme List Pages type: module description: Companion module for the OE List Pages module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - extra_field:extra_field - oe_list_pages:oe_list_page_content_type diff --git a/modules/oe_theme_paragraphs_contact/oe_theme_paragraphs_contact.info.yml b/modules/oe_theme_paragraphs_contact/oe_theme_paragraphs_contact.info.yml index abbc3626a..2015c4a70 100644 --- a/modules/oe_theme_paragraphs_contact/oe_theme_paragraphs_contact.info.yml +++ b/modules/oe_theme_paragraphs_contact/oe_theme_paragraphs_contact.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme Paragraphs Contact type: module description: Companion module for the OE Paragraphs Contact module package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 dependencies: - oe_paragraphs:oe_paragraphs_contact - oe_theme:oe_theme_content_entity_contact diff --git a/modules/oe_theme_test/oe_theme_test.info.yml b/modules/oe_theme_test/oe_theme_test.info.yml index c03391278..386d992d8 100644 --- a/modules/oe_theme_test/oe_theme_test.info.yml +++ b/modules/oe_theme_test/oe_theme_test.info.yml @@ -4,7 +4,7 @@ description: 'OpenEuropa theme test module.' package: OpenEuropa hidden: true version: VERSION -core: 8.x +core_version_requirement: ^8.9 || ^9.1 config_devel: install: diff --git a/oe_theme.info.yml b/oe_theme.info.yml index 3669493bc..14b916870 100644 --- a/oe_theme.info.yml +++ b/oe_theme.info.yml @@ -2,7 +2,7 @@ name: OpenEuropa Theme type: theme description: OpenEuropa base theme. package: OpenEuropa -core: 8.x +core_version_requirement: ^8.9 || ^9.1 base theme: stable diff --git a/oe_theme.theme b/oe_theme.theme index daea77072..18bb32105 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -454,13 +454,20 @@ function oe_theme_preprocess_field(&$variables, $hook): void { * Generates pagination items for ECL pagination component. */ function oe_theme_preprocess_pager(array &$variables): void { + /** @var \Drupal\Core\Pager\PagerManagerInterface $pager_manager */ + $pager_manager = \Drupal::service('pager.manager'); $element = $variables['pager']['#element']; $parameters = $variables['pager']['#parameters']; $route_name = $variables['pager']['#route_name']; $route_parameters = $variables['pager']['#route_parameters'] ?? []; + $pager = $pager_manager->getPager($element); global $pager_page_array, $pager_total; + // Nothing to do if there is no pager. + if (!isset($pager)) { + return; + } // Maximum page number for this pager. - $pager_max = $pager_total[$element]; + $pager_max = $pager->getTotalPages(); // Nothing to do if there is only one page. if ($pager_max <= 1) { return; @@ -469,7 +476,7 @@ function oe_theme_preprocess_pager(array &$variables): void { // The first and last page links are excluded from this count. $pager_offset = 2; // The page we are currently paged to. - $pager_current = $pager_page_array[$element] + 1; + $pager_current = $pager->getCurrentPage() + 1; // First page of the pagination calculated by offset from current. $pager_first = $pager_offset < $pager_current ? $pager_current - $pager_offset : 1; // Last page of the pagination calculated by offset from current. @@ -504,7 +511,7 @@ function oe_theme_preprocess_pager(array &$variables): void { // Add 'Previous' navigation link. if ($pager_current > 1) { $options = [ - 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1), + 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $pager->getCurrentPage() - 1), ]; $nav_link['link']['link'] = [ 'path' => Url::fromRoute($route_name, $route_parameters, $options), @@ -519,7 +526,7 @@ function oe_theme_preprocess_pager(array &$variables): void { // Add first page link. if ($pager_first != $pager_current) { $options = [ - 'query' => pager_query_add_page($parameters, $element, 0), + 'query' => $pager_manager->getUpdatedParameters($parameters, $element, 0), ]; $ecl_items[] = [ 'type' => 'first', @@ -554,7 +561,7 @@ function oe_theme_preprocess_pager(array &$variables): void { continue; } $options = [ - 'query' => pager_query_add_page($parameters, $element, $i - 1), + 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $i - 1), ]; $ecl_items[] = [ 'link' => [ @@ -576,7 +583,7 @@ function oe_theme_preprocess_pager(array &$variables): void { // Add last page link. if ($pager_max != $pager_current) { $options = [ - 'query' => pager_query_add_page($parameters, $element, $pager_max - 1), + 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $pager_max - 1), ]; $ecl_items[] = [ 'type' => 'last', @@ -593,7 +600,7 @@ function oe_theme_preprocess_pager(array &$variables): void { // Add 'Next' navigation link. if ($pager_current < $pager_max) { $options = [ - 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1), + 'query' => $pager_manager->getUpdatedParameters($parameters, $element, $pager->getCurrentPage() + 1), ]; $nav_link['link']['link'] = [ 'path' => Url::fromRoute($route_name, $route_parameters, $options), diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 329cfda6e..23d103d06 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - + @@ -9,11 +9,11 @@ - - - + + + - + ./modules/**/tests/ ./tests/ diff --git a/tests/Behat/OeThemeTestContext.php b/tests/Behat/OeThemeTestContext.php index dac195db3..85b5f2ed6 100644 --- a/tests/Behat/OeThemeTestContext.php +++ b/tests/Behat/OeThemeTestContext.php @@ -141,7 +141,7 @@ protected function getFieldNameByLabel(string $entity_type, string $label): stri } /** @var \Drupal\Core\Field\FieldConfigBase[] $fields */ - $fields = \Drupal::entityManager()->getFieldDefinitions('node', $entity_type); + $fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', $entity_type); foreach ($fields as $field) { if ($field instanceof FieldConfig && $field->label() === $label) { return $field->getName(); diff --git a/tests/EnsurePHPUnitBatchingTestListener.php b/tests/EnsurePHPUnitBatchingTestListener.php index 17c4cce42..b14a52e2d 100644 --- a/tests/EnsurePHPUnitBatchingTestListener.php +++ b/tests/EnsurePHPUnitBatchingTestListener.php @@ -6,21 +6,18 @@ use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\TestListener; -use PHPUnit\Framework\TestListenerDefaultImplementation; use PHPUnit\Runner\Exception; +use PHPUnit\Runner\TestHook; /** * Check if a test has been assigned to a test batch. */ -class EnsurePHPUnitBatchingTestListener implements TestListener { - - use TestListenerDefaultImplementation; +class EnsurePHPUnitBatchingTestListener implements TestHook { /** * {@inheritdoc} */ - public function startTest(Test $test) { + public function startTest(Test $test): void { if ($test instanceof TestCase) { $groups = $test->getGroups(); if (empty(preg_grep('/^batch(\d+)$/', $groups))) { diff --git a/tests/Functional/BreadcrumbTest.php b/tests/Functional/BreadcrumbTest.php index 0a5ab9f2a..559e5bc08 100644 --- a/tests/Functional/BreadcrumbTest.php +++ b/tests/Functional/BreadcrumbTest.php @@ -23,6 +23,12 @@ class BreadcrumbTest extends ContentRenderTestBase { 'block', ]; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * Tests that the breadcrumbs are cached correctly. */ diff --git a/tests/Functional/ConfigurationTest.php b/tests/Functional/ConfigurationTest.php index fcae38328..21cf74bf0 100755 --- a/tests/Functional/ConfigurationTest.php +++ b/tests/Functional/ConfigurationTest.php @@ -25,7 +25,12 @@ class ConfigurationTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. @@ -40,7 +45,7 @@ protected function setUp() { */ public function testDefaultLibraryLoading(): void { foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('theme_handler')->setDefault($active_theme); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); $this->drupalGet(''); @@ -71,7 +76,7 @@ public function testDefaultLibraryLoading(): void { */ public function testChangeComponentLibrary(): void { foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('theme_handler')->setDefault($active_theme); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); $page = $this->getSession()->getPage(); @@ -159,7 +164,7 @@ public function testChangeEclBranding(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('theme_handler')->setDefault($active_theme); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); // Create a user that does have permission to administer theme settings. diff --git a/tests/Functional/ContentCallForProposalsRenderTest.php b/tests/Functional/ContentCallForProposalsRenderTest.php index 1a12474f9..00a3a26a4 100644 --- a/tests/Functional/ContentCallForProposalsRenderTest.php +++ b/tests/Functional/ContentCallForProposalsRenderTest.php @@ -35,6 +35,12 @@ class ContentCallForProposalsRenderTest extends ContentRenderTestBase { 'oe_theme_content_call_proposals', ]; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentCallForTendersRenderTest.php b/tests/Functional/ContentCallForTendersRenderTest.php index 70ea92aca..b0b52aef9 100644 --- a/tests/Functional/ContentCallForTendersRenderTest.php +++ b/tests/Functional/ContentCallForTendersRenderTest.php @@ -34,6 +34,11 @@ class ContentCallForTendersRenderTest extends ContentRenderTestBase { 'datetime_testing', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * Tests that the Call for tenders page renders correctly. */ diff --git a/tests/Functional/ContentConsultationRenderTest.php b/tests/Functional/ContentConsultationRenderTest.php index 7ae33f276..3b7fae00f 100644 --- a/tests/Functional/ContentConsultationRenderTest.php +++ b/tests/Functional/ContentConsultationRenderTest.php @@ -39,6 +39,11 @@ class ContentConsultationRenderTest extends ContentRenderTestBase { 'oe_theme_content_consultation', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -253,7 +258,7 @@ public function testConsultationRendering(): void { $this->assertCount(4, $content_items); $content_second_group = $content_items[3]->find('css', '.ecl p'); $this->assertEquals('Consultation guidelines text', $content_second_group->getText()); - $this->assertElementNotPresent('.ecl-link.ecl-link--cta'); + $this->assertSession()->elementNotExists('css', '.ecl-link.ecl-link--cta'); // Set consultation outcome and outcome files and assert content is updated. $node->set('oe_consultation_outcome', 'Consultation outcome text'); @@ -546,7 +551,7 @@ public function testConsultationRendering(): void { $content_second_group = $content_items[3]->find('css', '.ecl'); $this->assertEquals('Consultation guidelines text', $content_second_group->getText()); - $this->assertNotContains('The response period for this consultation has ended. Thank you for your input.', $content_second_group->getText()); + $this->assertStringNotContainsString('The response period for this consultation has ended. Thank you for your input.', $content_second_group->getText()); // Add a link to respond button and assert default label. $node->set('oe_consultation_response_button', [ @@ -585,7 +590,7 @@ public function testConsultationRendering(): void { $content_second_group = $content_items[3]->find('css', '.ecl'); // Assert default value for closed status text. $this->assertEquals('The response period for this consultation has ended. Thank you for your input.', $content_second_group->getText()); - $this->assertElementNotPresent('.ecl-link.ecl-link--cta'); + $this->assertSession()->elementNotExists('css', '.ecl-link.ecl-link--cta'); // Set a value and assert the content is updated. $node->set('oe_consultation_closed_text', 'Consultation closed status text'); diff --git a/tests/Functional/ContentEventRenderTest.php b/tests/Functional/ContentEventRenderTest.php index 04da50d81..252088399 100644 --- a/tests/Functional/ContentEventRenderTest.php +++ b/tests/Functional/ContentEventRenderTest.php @@ -40,6 +40,11 @@ class ContentEventRenderTest extends ContentRenderTestBase { 'path', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentNewsRenderTest.php b/tests/Functional/ContentNewsRenderTest.php index 6b92cdfdc..92daa758a 100644 --- a/tests/Functional/ContentNewsRenderTest.php +++ b/tests/Functional/ContentNewsRenderTest.php @@ -30,6 +30,11 @@ class ContentNewsRenderTest extends ContentRenderTestBase { 'block', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -167,7 +172,7 @@ public function testNewsRendering(): void { $picture = $this->assertSession()->elementExists('css', 'article[role=article] article.ecl-u-type-paragraph.ecl-u-mb-l picture'); $image = $this->assertSession()->elementExists('css', 'img.ecl-u-width-100.ecl-u-height-auto', $picture); - $this->assertContains('placeholder_news_featured_media.png', $image->getAttribute('src')); + $this->assertStringContainsString('placeholder_news_featured_media.png', $image->getAttribute('src')); $this->assertEquals('Alternative text news_featured_media', $image->getAttribute('alt')); // Unpublish the media and assert it is not rendered anymore. diff --git a/tests/Functional/ContentOrganisationRenderTest.php b/tests/Functional/ContentOrganisationRenderTest.php index c2b0f2f57..08d35539c 100644 --- a/tests/Functional/ContentOrganisationRenderTest.php +++ b/tests/Functional/ContentOrganisationRenderTest.php @@ -37,6 +37,11 @@ class ContentOrganisationRenderTest extends ContentRenderTestBase { 'media_avportal_mock', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -115,7 +120,7 @@ public function testOrganisationRendering(): void { $assert->assertPattern($expected_values, $page_header->getOuterHtml()); $logo = $this->assertSession()->elementExists('css', '.ecl-col-l-3 img.ecl-media-container__media'); - $this->assertContains('styles/oe_theme_medium_no_crop/public/example_1.jpeg', $logo->getAttribute('src')); + $this->assertStringContainsString('styles/oe_theme_medium_no_crop/public/example_1.jpeg', $logo->getAttribute('src')); $this->assertEquals('Alt', $logo->getAttribute('alt')); // Add body text and contact values. @@ -154,7 +159,7 @@ public function testOrganisationRendering(): void { $this->drupalGet($node->toUrl()); $logo = $this->assertSession()->elementExists('css', '.ecl-col-l-3 img.ecl-media-container__media'); - $this->assertContains('files/styles/oe_theme_medium_no_crop/public/media_avportal_thumbnails/' . $file->getFilename(), $logo->getAttribute('src')); + $this->assertStringContainsString('files/styles/oe_theme_medium_no_crop/public/media_avportal_thumbnails/' . $file->getFilename(), $logo->getAttribute('src')); // Add overview values. $node->set('oe_organisation_overview', [ @@ -270,7 +275,7 @@ public function testOrganisationRendering(): void { $content_items = $content->findAll('xpath', '/div'); $person_content = $content_items[2]->findAll('css', 'article.ecl-u-d-flex.ecl-u-pv-m.ecl-u-border-bottom.ecl-u-border-color-grey-15'); $this->assertCount(1, $person_content); - $this->assertContains('node/2', $person_content[0]->find('css', 'a.ecl-link.ecl-link--standalone')->getAttribute('href')); + $this->assertStringContainsString('node/2', $person_content[0]->find('css', 'a.ecl-link.ecl-link--standalone')->getAttribute('href')); // Assert person content. $first_person_image = $person_content[0]->find('css', '.ecl-u-flex-shrink-0.ecl-u-mr-s.ecl-u-media-a-s.ecl-u-media-bg-size-contain.ecl-u-media-bg-repeat-none'); // Assert default image. diff --git a/tests/Functional/ContentPersonRenderTest.php b/tests/Functional/ContentPersonRenderTest.php index 8b164a01c..b7562e088 100644 --- a/tests/Functional/ContentPersonRenderTest.php +++ b/tests/Functional/ContentPersonRenderTest.php @@ -40,6 +40,11 @@ class ContentPersonRenderTest extends ContentRenderTestBase { 'oe_theme_content_person', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -85,7 +90,7 @@ public function testPersonRendering(): void { // Assert content. $portrait = $this->assertSession()->elementExists('css', 'article .ecl-col-l-3 img.ecl-media-container__media'); - $this->assertContains('/themes/custom/oe_theme/images/user_icon.svg', $portrait->getAttribute('src')); + $this->assertStringContainsString('/themes/custom/oe_theme/images/user_icon.svg', $portrait->getAttribute('src')); $this->assertEmpty($portrait->getAttribute('alt')); $this->assertSession()->pageTextNotContains('Page contents'); $content = $this->assertSession()->elementExists('css', 'article .ecl-col-l-9'); @@ -109,14 +114,14 @@ public function testPersonRendering(): void { $portrait_media = $this->createMediaImage('portrait'); $node->set('oe_person_photo', $portrait_media)->save(); $this->drupalGet($node->toUrl()); - $this->assertContains('/files/styles/oe_theme_medium_no_crop/public/placeholder_portrait.png', $portrait->getAttribute('src')); + $this->assertStringContainsString('/files/styles/oe_theme_medium_no_crop/public/placeholder_portrait.png', $portrait->getAttribute('src')); $this->assertEquals('Alternative text portrait', $portrait->getAttribute('alt')); // Unpublish the media and assert it is not rendered anymore. $portrait_media->set('status', 0); $portrait_media->save(); $this->drupalGet($node->toUrl()); - $this->assertNotContains('/files/styles/oe_theme_medium_no_crop/public/placeholder_portrait.png', $portrait->getAttribute('src')); + $this->assertStringNotContainsString('/files/styles/oe_theme_medium_no_crop/public/placeholder_portrait.png', $portrait->getAttribute('src')); // Publish the media. $portrait_media->set('status', 1); @@ -310,9 +315,9 @@ public function testPersonRendering(): void { // structure so no need to test. $first_item = $items[0]->find('css', 'img'); $this->assertEquals('Alternative text first_media', $first_item->getAttribute('alt')); - $this->assertContains('/styles/large/public/placeholder_first_media.png?itok=', $first_item->getAttribute('src')); + $this->assertStringContainsString('/styles/large/public/placeholder_first_media.png?itok=', $first_item->getAttribute('src')); $caption = $items[0]->find('css', '.ecl-gallery__description'); - $this->assertContains('Test image first_media', $caption->getOuterHtml()); + $this->assertStringContainsString('Test image first_media', $caption->getOuterHtml()); $this->assertEmpty($caption->find('css', '.ecl-gallery__meta')->getText()); // Assert Transparency introduction field. diff --git a/tests/Functional/ContentProjectRenderTest.php b/tests/Functional/ContentProjectRenderTest.php index 289d344fc..172181fb3 100644 --- a/tests/Functional/ContentProjectRenderTest.php +++ b/tests/Functional/ContentProjectRenderTest.php @@ -34,6 +34,11 @@ class ContentProjectRenderTest extends ContentRenderTestBase { 'options', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -147,7 +152,7 @@ public function testProjectRendering(): void { $project_details = $this->assertSession()->elementExists('css', 'div#project-details'); // Assert the body text. - $this->assertContains('Body', $project_details->getText()); + $this->assertStringContainsString('Body', $project_details->getText()); $this->assertFeaturedMediaField($project_details, 'project_featured_media'); // Assert the description blocks inside the Project details. @@ -232,7 +237,7 @@ public function testProjectRendering(): void { $project_results = $this->assertSession()->elementExists('css', 'div#project-results'); // Assert results text. - $this->assertContains('Project results...', $project_results->getText()); + $this->assertStringContainsString('Project results...', $project_results->getText()); // Assert result file. $file_wrapper = $project_results->find('css', 'div.ecl-file'); @@ -356,7 +361,7 @@ protected function assertStakeholderOrganisationRendering(NodeElement $rendered_ // Assert logo. $logos = $rendered_stakeholder_element->findAll('css', 'div[role=img]'); $this->assertCount(1, $logos); - $this->assertContains("placeholder_$name.png", $logos[0]->getAttribute('style')); + $this->assertStringContainsString("placeholder_$name.png", $logos[0]->getAttribute('style')); // Assert the Organisation contacts list block's labels and values. $field_list_assert = new FieldListAssert(); @@ -379,7 +384,7 @@ protected function assertStakeholderOrganisationRendering(NodeElement $rendered_ // Assert contact link. $contact_links = $rendered_stakeholder_element->findAll('css', '.ecl-link'); $this->assertCount(1, $contact_links); - $this->assertContains("http://example.com/contact_$name", $contact_links[0]->getAttribute('href')); + $this->assertStringContainsString("http://example.com/contact_$name", $contact_links[0]->getAttribute('href')); $contact_link_labels = $rendered_stakeholder_element->findAll('css', '.ecl-link__label'); $this->assertCount(1, $contact_link_labels); $this->assertEquals('Contact organisation', $contact_link_labels[0]->getText()); diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/Functional/ContentPublicationRenderTest.php index fa1fd2866..1148392e4 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/Functional/ContentPublicationRenderTest.php @@ -32,6 +32,11 @@ class ContentPublicationRenderTest extends ContentRenderTestBase { 'oe_theme_content_organisation_reference', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -271,8 +276,8 @@ public function testPublicationRendering(): void { $thumbnail_wrapper = $this->assertSession()->elementExists('css', $thumbnail_wrapper_selector); $image_element = $this->assertSession()->elementExists('css', 'img', $thumbnail_wrapper); - $this->assertContains("placeholder_publication_image.png", $image_element->getAttribute('src')); - $this->assertContains("oe_theme_publication_thumbnail", $image_element->getAttribute('src')); + $this->assertStringContainsString("placeholder_publication_image.png", $image_element->getAttribute('src')); + $this->assertStringContainsString("oe_theme_publication_thumbnail", $image_element->getAttribute('src')); $this->assertEquals("Alternative text publication_image", $image_element->getAttribute('alt')); // Unpublish the media and assert it is not rendered anymore. diff --git a/tests/Functional/ContentRenderTestBase.php b/tests/Functional/ContentRenderTestBase.php index d4c56523e..3fb4181c4 100644 --- a/tests/Functional/ContentRenderTestBase.php +++ b/tests/Functional/ContentRenderTestBase.php @@ -23,6 +23,11 @@ */ abstract class ContentRenderTestBase extends BrowserTestBase { + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -110,14 +115,14 @@ protected function assertMediaDocumentDefaultRender(NodeElement $element, string $file_wrapper = $element->find('css', 'div.ecl-file'); $file_row = $file_wrapper->find('css', '.ecl-file .ecl-file__container'); $file_title = $file_row->find('css', '.ecl-file__title'); - $this->assertContains($name, $file_title->getText()); + $this->assertStringContainsString($name, $file_title->getText()); $file_info_language = $file_row->find('css', '.ecl-file__info div.ecl-file__language'); - $this->assertContains($language, $file_info_language->getText()); + $this->assertStringContainsString($language, $file_info_language->getText()); $file_info_properties = $file_row->find('css', '.ecl-file__info div.ecl-file__meta'); - $this->assertContains("($meta)", $file_info_properties->getText()); + $this->assertStringContainsString("($meta)", $file_info_properties->getText()); $file_download_link = $file_row->find('css', '.ecl-file__download'); - $this->assertContains($link, $file_download_link->getAttribute('href')); - $this->assertContains($button_label, $file_download_link->getText()); + $this->assertStringContainsString($link, $file_download_link->getAttribute('href')); + $this->assertStringContainsString($button_label, $file_download_link->getText()); } /** @@ -165,7 +170,7 @@ protected function assertFeaturedMediaField(NodeElement $rendered_element, strin // Assert image tag. $image = $figure->find('css', 'img'); - $this->assertContains("placeholder_$name.png", $image->getAttribute('src')); + $this->assertStringContainsString("placeholder_$name.png", $image->getAttribute('src')); $this->assertEquals("Alternative text $name", $image->getAttribute('alt')); // Assert caption. @@ -378,7 +383,7 @@ protected function assertLinkIcon(NodeElement $element, string $title, string $h $this->assertCount(1, $svg); $icon = $svg[0]->findAll('css', 'use'); $this->assertCount(1, $icon); - $this->assertContains($icon_type, $icon[0]->getAttribute('xlink:href')); + $this->assertStringContainsString($icon_type, $icon[0]->getAttribute('xlink:href')); } /** diff --git a/tests/Functional/CorporateFooterRenderTest.php b/tests/Functional/CorporateFooterRenderTest.php index ccc11a223..145d2cc28 100644 --- a/tests/Functional/CorporateFooterRenderTest.php +++ b/tests/Functional/CorporateFooterRenderTest.php @@ -39,6 +39,11 @@ class CorporateFooterRenderTest extends BrowserTestBase { 'oe_corporate_blocks', ]; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -47,7 +52,7 @@ protected function setUp(): void { // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by diff --git a/tests/Functional/ParagraphsTest.php b/tests/Functional/ParagraphsTest.php index 4080eff74..ae203cecf 100644 --- a/tests/Functional/ParagraphsTest.php +++ b/tests/Functional/ParagraphsTest.php @@ -28,7 +28,12 @@ class ParagraphsTest extends BrowserTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. @@ -67,7 +72,7 @@ public function testAccordionItemParagraph(): void { 'field_oe_demo_body[0][subform][field_oe_paragraphs][0][subform][field_oe_text_long][0][value]' => 'Accordion item body', 'oe_content_content_owner[0][target_id]' => 'Directorate-General for Informatics', ]; - $this->drupalPostForm(NULL, $values, 'Save'); + $this->submitForm($values, 'Save'); $this->drupalGet('/node/1'); // Assert paragraph values are displayed. diff --git a/tests/FunctionalJavascript/JavascriptBehavioursTest.php b/tests/FunctionalJavascript/JavascriptBehavioursTest.php index 1c6edfe53..669285207 100644 --- a/tests/FunctionalJavascript/JavascriptBehavioursTest.php +++ b/tests/FunctionalJavascript/JavascriptBehavioursTest.php @@ -29,12 +29,17 @@ class JavascriptBehavioursTest extends WebDriverTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected $defaultTheme = 'stark'; + + /** + * {@inheritdoc} + */ + protected function setUp(): void { parent::setUp(); // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } @@ -172,7 +177,7 @@ public function testEclDatePicker(): void { // Assert some small differences on the second date input element. $input = $this->getSession()->getPage()->find('css', 'input[name="test_datepicker_two"]'); $this->assertEquals('YYYY-MM-DD', $input->getAttribute('placeholder')); - $this->assertContains('2020-05-10', $input->getAttribute('value')); + $this->assertStringContainsString('2020-05-10', $input->getAttribute('value')); $this->assertTrue($input->hasAttribute('data-ecl-datepicker-toggle')); $this->assertFalse($input->hasAttribute('required')); diff --git a/tests/Kernel/AbstractKernelTestBase.php b/tests/Kernel/AbstractKernelTestBase.php index c72bd7d72..e5edd1f8c 100644 --- a/tests/Kernel/AbstractKernelTestBase.php +++ b/tests/Kernel/AbstractKernelTestBase.php @@ -35,7 +35,7 @@ abstract class AbstractKernelTestBase extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); @@ -49,7 +49,7 @@ protected function setUp() { ]); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Call the install hook of the User module which creates the Anonymous user diff --git a/tests/Kernel/BlockTest.php b/tests/Kernel/BlockTest.php index 876ca07f4..d833e7609 100644 --- a/tests/Kernel/BlockTest.php +++ b/tests/Kernel/BlockTest.php @@ -38,7 +38,7 @@ class BlockTest extends EntityKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); @@ -52,7 +52,7 @@ protected function setUp() { ]); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } @@ -83,7 +83,7 @@ public function testBlockTitles(): void { ]); $block_content->save(); $block = $this->placeBlock('block_content:' . $block_content->uuid()); - $build = $this->container->get('entity.manager')->getViewBuilder('block')->view($block, 'block'); + $build = $this->container->get('entity_type.manager')->getViewBuilder('block')->view($block, 'block'); $crawler = new Crawler($this->renderRoot($build)); diff --git a/tests/Kernel/BreadcrumbTest.php b/tests/Kernel/BreadcrumbTest.php index 506dc67ad..5966afa49 100644 --- a/tests/Kernel/BreadcrumbTest.php +++ b/tests/Kernel/BreadcrumbTest.php @@ -40,14 +40,14 @@ class BreadcrumbTest extends EntityKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); $this->installConfig(['system', 'image', 'responsive_image']); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Call the install hook of the User module which creates the Anonymous user diff --git a/tests/Kernel/CallForProposalsRenderTest.php b/tests/Kernel/CallForProposalsRenderTest.php index eaf790964..6beba4a13 100644 --- a/tests/Kernel/CallForProposalsRenderTest.php +++ b/tests/Kernel/CallForProposalsRenderTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/CallForTendersRenderTest.php b/tests/Kernel/CallForTendersRenderTest.php index babaa7b98..14a143d3f 100644 --- a/tests/Kernel/CallForTendersRenderTest.php +++ b/tests/Kernel/CallForTendersRenderTest.php @@ -54,7 +54,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/ConsultationRenderTest.php b/tests/Kernel/ConsultationRenderTest.php index 8ed74513b..9699bdd3a 100644 --- a/tests/Kernel/ConsultationRenderTest.php +++ b/tests/Kernel/ConsultationRenderTest.php @@ -51,7 +51,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/ContactFormRenderTest.php b/tests/Kernel/ContactFormRenderTest.php index 89097cc9a..80730eb95 100644 --- a/tests/Kernel/ContactFormRenderTest.php +++ b/tests/Kernel/ContactFormRenderTest.php @@ -36,7 +36,7 @@ protected function setUp(): void { $this->installConfig(['system', 'image', 'responsive_image', 'contact']); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } @@ -84,8 +84,8 @@ public function testContactForm(): void { $actual = $crawler->filter('.ecl-u-mv-m'); $this->assertCount(7, $actual); $telephone = $crawler->filter('.field--name-oe-telephone input'); - $this->assertEqual(60, $telephone->attr('size')); - $this->assertContains('ecl-text-input', $telephone->attr('class')); + $this->assertEquals($telephone->attr('size'), 60); + $this->assertStringContainsString('ecl-text-input', $telephone->attr('class')); /** @var \Drupal\Core\Messenger\MessengerInterface $messenger */ $messenger = $this->container->get('messenger'); diff --git a/tests/Kernel/ContactRenderTest.php b/tests/Kernel/ContactRenderTest.php index ff1aa1010..48d2949eb 100644 --- a/tests/Kernel/ContactRenderTest.php +++ b/tests/Kernel/ContactRenderTest.php @@ -27,7 +27,7 @@ class ContactRenderTest extends ContentRenderTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('oe_contact'); @@ -250,7 +250,7 @@ protected function assertFeaturedMediaField(string $html, string $name): void { // Assert image tag. $image = $figure->filter('img'); - $this->assertContains("placeholder_$name.png", $image->attr('src')); + $this->assertStringContainsString("placeholder_$name.png", $image->attr('src')); $this->assertEquals("Alternative text $name", $image->attr('alt')); // Assert caption. diff --git a/tests/Kernel/ContentLanguageSwitcherTest.php b/tests/Kernel/ContentLanguageSwitcherTest.php index b1aaeaf9e..6cea36cee 100644 --- a/tests/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/Kernel/ContentLanguageSwitcherTest.php @@ -29,7 +29,7 @@ class ContentLanguageSwitcherTest extends MultilingualAbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('node'); diff --git a/tests/Kernel/ContentRenderTestBase.php b/tests/Kernel/ContentRenderTestBase.php index 8ffbfd21b..502034741 100644 --- a/tests/Kernel/ContentRenderTestBase.php +++ b/tests/Kernel/ContentRenderTestBase.php @@ -85,7 +85,7 @@ abstract class ContentRenderTestBase extends MultilingualAbstractKernelTestBase /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->setUpSparql(); @@ -116,7 +116,7 @@ protected function setUp() { $this->container->get('config.installer')->installDefaultConfig('theme', 'oe_theme'); $this->container->get('module_handler')->loadInclude('oe_content_documents_field', 'install'); - oe_content_documents_field_install(); + oe_content_documents_field_install(FALSE); $this->installConfig([ 'oe_content', @@ -142,7 +142,7 @@ protected function setUp() { ->save(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); $this->installEntitySchema('skos_concept'); $this->installEntitySchema('skos_concept_scheme'); diff --git a/tests/Kernel/EventRenderTest.php b/tests/Kernel/EventRenderTest.php index 5c4b10eaf..d14587549 100644 --- a/tests/Kernel/EventRenderTest.php +++ b/tests/Kernel/EventRenderTest.php @@ -67,7 +67,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/LanguageSwitcherTest.php b/tests/Kernel/LanguageSwitcherTest.php index 61b33c6a0..dbbfb0f0a 100644 --- a/tests/Kernel/LanguageSwitcherTest.php +++ b/tests/Kernel/LanguageSwitcherTest.php @@ -156,7 +156,7 @@ public function testLanguageSwitcherRendering(string $langcode, string $lang_pre // Make sure that language switcher link is properly rendered. $actual = $crawler->filter('a[data-ecl-language-selector]')->text(); - $this->assertContains($language_name, $actual); + $this->assertStringContainsString($language_name, $actual); $actual = $crawler->filter('a[data-ecl-language-selector] .ecl-site-header-core__language-code')->text(); $this->assertEquals($lang_prefix, $actual); diff --git a/tests/Kernel/LegacyContentRenderTest.php b/tests/Kernel/LegacyContentRenderTest.php index b664eaa06..106d7e30d 100644 --- a/tests/Kernel/LegacyContentRenderTest.php +++ b/tests/Kernel/LegacyContentRenderTest.php @@ -50,11 +50,11 @@ public function testPage(): void { // Body wrapper. $body_wrapper = $crawler->filter('.ecl'); $this->assertCount(1, $body_wrapper); - $this->assertContains('Body', $body_wrapper->text()); + $this->assertStringContainsString('Body', $body_wrapper->text()); // Related links. $related_links_heading = $crawler->filter('.ecl-u-type-heading-2'); - $this->assertContains('Related links', $related_links_heading->text()); + $this->assertStringContainsString('Related links', $related_links_heading->text()); $related_links = $crawler->filter('.ecl-list .ecl-link.ecl-link--standalone'); $this->assertCount(2, $related_links); @@ -92,7 +92,7 @@ public function testPolicy(): void { // Body wrapper. $body_wrapper = $crawler->filter('.ecl'); $this->assertCount(1, $body_wrapper); - $this->assertContains('Body', $body_wrapper->text()); + $this->assertStringContainsString('Body', $body_wrapper->text()); // Test short title fallback. $node->set('oe_content_short_title', 'Policy short title')->save(); @@ -156,17 +156,17 @@ public function testPublication(): void { $this->assertCount(1, $file_row); $file_title = $file_row->filter('.ecl-file__title'); - $this->assertContains('test document', $file_title->text()); + $this->assertStringContainsString('test document', $file_title->text()); $file_info_language = $file_row->filter('.ecl-file__info div.ecl-file__language'); - $this->assertContains('English', $file_info_language->text()); + $this->assertStringContainsString('English', $file_info_language->text()); $file_info_properties = $file_row->filter('.ecl-file__info div.ecl-file__meta'); - $this->assertContains('KB - PDF)', $file_info_properties->text()); + $this->assertStringContainsString('KB - PDF)', $file_info_properties->text()); $file_download_link = $file_row->filter('.ecl-file__download'); - $this->assertContains('/test.pdf', $file_download_link->attr('href')); - $this->assertContains('Download', $file_download_link->text()); + $this->assertStringContainsString('/test.pdf', $file_download_link->attr('href')); + $this->assertStringContainsString('Download', $file_download_link->text()); } } diff --git a/tests/Kernel/MainMenuTest.php b/tests/Kernel/MainMenuTest.php index 557122d46..e8268842b 100644 --- a/tests/Kernel/MainMenuTest.php +++ b/tests/Kernel/MainMenuTest.php @@ -28,7 +28,7 @@ class MainMenuTest extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('menu_link_content'); diff --git a/tests/Kernel/MediaRenderTest.php b/tests/Kernel/MediaRenderTest.php index 053cf380b..ac2dd13fa 100644 --- a/tests/Kernel/MediaRenderTest.php +++ b/tests/Kernel/MediaRenderTest.php @@ -50,7 +50,7 @@ class MediaRenderTest extends MultilingualAbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installSchema('file', 'file_usage'); diff --git a/tests/Kernel/MenuLocalTasksTest.php b/tests/Kernel/MenuLocalTasksTest.php index 5b80baace..930d0b991 100644 --- a/tests/Kernel/MenuLocalTasksTest.php +++ b/tests/Kernel/MenuLocalTasksTest.php @@ -51,7 +51,6 @@ public function testMenuLocalTasks(): void { '#weight' => 0, ], ], - '#user' => $this->user, ]; $html = $this->renderRoot($render); diff --git a/tests/Kernel/MultilingualAbstractKernelTestBase.php b/tests/Kernel/MultilingualAbstractKernelTestBase.php index 165cef8c5..9196bac26 100644 --- a/tests/Kernel/MultilingualAbstractKernelTestBase.php +++ b/tests/Kernel/MultilingualAbstractKernelTestBase.php @@ -35,7 +35,7 @@ abstract class MultilingualAbstractKernelTestBase extends AbstractKernelTestBase /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installSchema('locale', [ diff --git a/tests/Kernel/NewsRenderTest.php b/tests/Kernel/NewsRenderTest.php index 6fef6e0b0..1ba38a043 100644 --- a/tests/Kernel/NewsRenderTest.php +++ b/tests/Kernel/NewsRenderTest.php @@ -24,7 +24,7 @@ protected function setUp(): void { parent::setUp(); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); } /** diff --git a/tests/Kernel/OrganisationRenderTest.php b/tests/Kernel/OrganisationRenderTest.php index a0834b2a1..9acc75a7b 100644 --- a/tests/Kernel/OrganisationRenderTest.php +++ b/tests/Kernel/OrganisationRenderTest.php @@ -62,7 +62,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/PagerTest.php b/tests/Kernel/PagerTest.php index 7c097e104..06adc4f8a 100644 --- a/tests/Kernel/PagerTest.php +++ b/tests/Kernel/PagerTest.php @@ -36,6 +36,13 @@ class PagerTest extends AbstractKernelTestBase { * @throws \Exception */ public function testMultiplePagers(): void { + \Drupal::request()->query->set('page', '6,0,14'); + + $pager_manager = \Drupal::service('pager.manager'); + $pager_manager->createPager(100, 7, 0); + $pager_manager->createPager(100, 7, 1); + $pager_manager->createPager(100, 7, 2); + // Set up a render array. $build['pager_0'] = [ '#type' => 'pager', @@ -50,17 +57,6 @@ public function testMultiplePagers(): void { '#element' => 2, ]; - // Initialize pagers with some fake data. - pager_default_initialize(100, 7, 0); - pager_default_initialize(100, 7, 1); - pager_default_initialize(100, 7, 2); - - // Set up the current page numbers for pagers. - global $pager_page_array; - $pager_page_array[0] = 6; - $pager_page_array[1] = 0; - $pager_page_array[2] = 14; - // Rendering the markup. $html = $this->renderRoot($build); $crawler = new Crawler($html); @@ -74,36 +70,36 @@ public function testMultiplePagers(): void { // Assert that the pager contain 'next' and 'previous' page links. $previous = $first_pager->filter('li.ecl-pagination__item--previous'); $this->assertSpecialPagerElement($previous, TRUE, $this->generatePagerUrl('', 6), 'Go to previous page'); - $this->assertContains(self::PREVIOUS_PAGE_LINK_TEXT, $first_pager->text()); + $this->assertStringContainsString(self::PREVIOUS_PAGE_LINK_TEXT, $first_pager->text()); $next = $first_pager->filter('li.ecl-pagination__item--next'); $this->assertSpecialPagerElement($next, TRUE, $this->generatePagerUrl('', 8), 'Go to next page'); - $this->assertContains(self::NEXT_PAGE_LINK_TEXT, $first_pager->text()); + $this->assertStringContainsString(self::NEXT_PAGE_LINK_TEXT, $first_pager->text()); // Assert that the pager contain two ellipsis elements. $ellipsis_count = $first_pager->filter('li.ecl-pagination__item--ellipsis'); $this->assertCount(2, $ellipsis_count); // Assert the current page number. $current_page_number = $first_pager->filter('li.ecl-pagination__item--current')->html(); - $this->assertContains('Page 7', $current_page_number); + $this->assertStringContainsString('Page 7', $current_page_number); // Check the second variant (pager set on the first page). $second_pager = $crawler->filter('nav:nth-of-type(2)'); // Assert that the pager contains only the 'next' page link. - $this->assertContains(self::NEXT_PAGE_LINK_TEXT, $second_pager->text()); - $this->assertNotContains(self::PREVIOUS_PAGE_LINK_TEXT, $second_pager->text()); + $this->assertStringContainsString(self::NEXT_PAGE_LINK_TEXT, $second_pager->text()); + $this->assertStringNotContainsString(self::PREVIOUS_PAGE_LINK_TEXT, $second_pager->text()); // Assert that the pager is set on the first page. $first_page_number = $second_pager->filter('li.ecl-pagination__item--current')->html(); - $this->assertContains('Page 1', $first_page_number); + $this->assertStringContainsString('Page 1', $first_page_number); // Check the third variant (pager set on the last page). $third_pager = $crawler->filter('nav:nth-of-type(3)'); // Assert that the pager contains only the 'previous' page link. - $this->assertContains(self::PREVIOUS_PAGE_LINK_TEXT, $third_pager->text()); - $this->assertNotContains(self::NEXT_PAGE_LINK_TEXT, $third_pager->text()); + $this->assertStringContainsString(self::PREVIOUS_PAGE_LINK_TEXT, $third_pager->text()); + $this->assertStringNotContainsString(self::NEXT_PAGE_LINK_TEXT, $third_pager->text()); // Assert that the pager is set on the last page. $first_page_number = $third_pager->filter('li.ecl-pagination__item--current')->html(); - $this->assertContains('Page 15', $first_page_number); + $this->assertStringContainsString('Page 15', $first_page_number); } /** @@ -125,16 +121,17 @@ public function testMultiplePagers(): void { * @SuppressWarnings(PHPMD.NPathComplexity) */ public function testSinglePager(int $current_page, int $total_pages, string $route_name = ''): void { + \Drupal::request()->query->set('page', $current_page - 1); + + $pager_manager = \Drupal::service('pager.manager'); + $pager_manager->createPager($total_pages * 10, 10, 0); + $build['pager'] = [ - '#type' => 'pager', '#route_name' => $route_name, + '#type' => 'pager', + '#element' => 0, ]; - pager_default_initialize($total_pages * 10, 10); - - global $pager_page_array; - // Normalise the current page array to 0-based. - $pager_page_array[0] = $current_page - 1; $html = $this->renderRoot($build); $crawler = new Crawler($html); @@ -144,7 +141,7 @@ public function testSinglePager(int $current_page, int $total_pages, string $rou // Assert that the current page set is correct. $current_page_element = $wrapper->filter('li.ecl-pagination__item--current'); - $this->assertContains('Page ' . $current_page, $current_page_element->html()); + $this->assertStringContainsString('Page ' . $current_page, $current_page_element->html()); // By specifications, the following links should be visible: // - links to the previous two pages (if applicable); @@ -184,7 +181,7 @@ public function testSinglePager(int $current_page, int $total_pages, string $rou $previous = $crawler->filter('li.ecl-pagination__item--previous'); $this->assertSpecialPagerElement($previous, $show_start_links, $this->generatePagerUrl($route_name, $current_page - 1), 'Go to previous page'); - $this->{$show_start_links ? 'assertContains' : 'assertNotContains'}(self::PREVIOUS_PAGE_LINK_TEXT, $crawler->html()); + $this->{$show_start_links ? 'assertStringContainsString' : 'assertStringNotContainsString'}(self::PREVIOUS_PAGE_LINK_TEXT, $crawler->html()); $first_page = $crawler->filter('li.ecl-pagination__item--first'); $this->assertSpecialPagerElement($first_page, $show_start_links, $this->generatePagerUrl($route_name, 1), 'Go to page 1'); @@ -197,7 +194,7 @@ public function testSinglePager(int $current_page, int $total_pages, string $rou $next = $crawler->filter('li.ecl-pagination__item--next'); $this->assertSpecialPagerElement($next, $show_end_links, $this->generatePagerUrl($route_name, $current_page + 1), 'Go to next page'); - $this->{$show_end_links ? 'assertContains' : 'assertNotContains'}(self::NEXT_PAGE_LINK_TEXT, $crawler->html()); + $this->{$show_end_links ? 'assertStringContainsString' : 'assertStringNotContainsString'}(self::NEXT_PAGE_LINK_TEXT, $crawler->html()); $last_page = $crawler->filter('li.ecl-pagination__item--last'); $this->assertSpecialPagerElement($last_page, $show_end_links, $this->generatePagerUrl($route_name, $total_pages), "Go to page $total_pages"); @@ -285,8 +282,9 @@ protected function assertSpecialPagerElement(Crawler $element, bool $should_be_p * A string URL. */ protected function generatePagerUrl(string $route_name, int $page, int $element = 0): string { + $pager_manager = \Drupal::service('pager.manager'); $options = [ - 'query' => pager_query_add_page([], $element, $page - 1), + 'query' => $pager_manager->getUpdatedParameters([], $element, $page - 1), ]; return Url::fromRoute($route_name, [], $options)->toString(); diff --git a/tests/Kernel/Paragraphs/ContactParagraphTest.php b/tests/Kernel/Paragraphs/ContactParagraphTest.php index e1561d053..07e1517dc 100644 --- a/tests/Kernel/Paragraphs/ContactParagraphTest.php +++ b/tests/Kernel/Paragraphs/ContactParagraphTest.php @@ -40,7 +40,7 @@ class ContactParagraphTest extends ParagraphsTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('media'); @@ -142,7 +142,7 @@ public function testContact(): void { $this->assertEquals('general@example.com', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(4) div a')->html())); $this->assertEquals('Address of General contact, 1001 Brussels, Belgium', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(6) div span')->html())); $this->assertEquals('Facebook', trim($crawler->filter('dl.ecl-description-list.ecl-description-list--horizontal:nth-child(2) dd.ecl-description-list__definition:nth-child(8) div div div a span')->html())); - $this->assertContains('example_1.jpeg', $crawler->filter('div.ecl-col-m-5 figure.ecl-media-container img')->attr('src')); + $this->assertStringContainsString('example_1.jpeg', $crawler->filter('div.ecl-col-m-5 figure.ecl-media-container img')->attr('src')); // Assert rendering of the second contact. $this->assertEquals('Press contact', trim($crawler->filter('div.ecl-row.ecl-u-mv-xl:nth-child(2) h3.ecl-u-type-heading-3.ecl-u-mt-none div')->html())); $this->assertEquals('

Press contact body text

', trim($crawler->filter('div.ecl-col-12:nth-child(2) div.ecl-u-mb-l div.ecl')->html())); diff --git a/tests/Kernel/Paragraphs/ContentRowTest.php b/tests/Kernel/Paragraphs/ContentRowTest.php index 2dde8cfb4..849df1259 100644 --- a/tests/Kernel/Paragraphs/ContentRowTest.php +++ b/tests/Kernel/Paragraphs/ContentRowTest.php @@ -97,16 +97,16 @@ public function testRendering(): void { // Verify that there is a full size column rendered. $this->assertCount(1, $crawler->filter('.ecl-row .ecl-col-m-12')); // Do a smoke test that inner paragraphs are rendered. - $this->assertContains('Links block title', $html); - $this->assertContains('List item title', $html); - $this->assertContains('List block title', $html); - $this->assertContains('Rich text without title.', $html); - $this->assertContains('Rich text with title.', $html); + $this->assertStringContainsString('Links block title', $html); + $this->assertStringContainsString('List item title', $html); + $this->assertStringContainsString('List block title', $html); + $this->assertStringContainsString('Rich text without title.', $html); + $this->assertStringContainsString('Rich text with title.', $html); // No page navigation should be shown. $this->assertCount(0, $crawler->filter('.ecl-inpage-navigation')); // Neither the title. - $this->assertNotContains('Page navigation', $html); + $this->assertStringNotContainsString('Page navigation', $html); // Change variant to the inpage navigation. $paragraph->get('oe_paragraphs_variant')->setValue('inpage_navigation'); @@ -121,11 +121,11 @@ public function testRendering(): void { // Verify that the right column still contains all the paragraphs. $right_column_html = $right_column->html(); - $this->assertContains('Links block title', $right_column_html); - $this->assertContains('List item title', $right_column_html); - $this->assertContains('List block title', $right_column_html); - $this->assertContains('Rich text without title.', $right_column_html); - $this->assertContains('Rich text with title.', $right_column_html); + $this->assertStringContainsString('Links block title', $right_column_html); + $this->assertStringContainsString('List item title', $right_column_html); + $this->assertStringContainsString('List block title', $right_column_html); + $this->assertStringContainsString('Rich text without title.', $right_column_html); + $this->assertStringContainsString('Rich text with title.', $right_column_html); // Verify that the inpage navigation title has been rendered. $this->assertEquals('Page navigation', trim($left_column->filter('.ecl-inpage-navigation__title')->text())); @@ -146,7 +146,7 @@ public function testRendering(): void { // Assert that side-menu is correctly rendered with the default title. $left_column = $crawler->filter('.ecl-row .ecl-col-l-3.ecl-u-z-navigation'); - $this->assertContains('Page contents', $left_column->html()); + $this->assertStringContainsString('Page contents', $left_column->html()); } /** @@ -186,16 +186,16 @@ public function testSideMenuTranslation(): void { // Assert that side-menu "English" translation is correctly rendered. $left_column = $crawler->filter('.ecl-row .ecl-col-l-3.ecl-u-z-navigation'); - $this->assertContains('English page navigation', $left_column->html()); - $this->assertContains('English rich text title', $left_column->html()); + $this->assertStringContainsString('English page navigation', $left_column->html()); + $this->assertStringContainsString('English rich text title', $left_column->html()); $html = $this->renderParagraph($paragraph, 'fr'); $crawler = new Crawler($html); // Assert that side-menu "French" translation is correctly rendered. $left_column = $crawler->filter('.ecl-row .ecl-col-l-3.ecl-u-z-navigation'); - $this->assertContains('French page navigation', $left_column->html()); - $this->assertContains('French rich text title', $left_column->html()); + $this->assertStringContainsString('French page navigation', $left_column->html()); + $this->assertStringContainsString('French rich text title', $left_column->html()); } /** @@ -211,7 +211,7 @@ public function testSideMenuTranslation(): void { protected function assertNavigationItem(Crawler $item, string $title, Crawler $content) { $link = $item->filter('a'); $this->assertEquals($title, trim($link->text())); - $this->assertContains($title, $content->filter($link->attr('href'))->html()); + $this->assertStringContainsString($title, $content->filter($link->attr('href'))->html()); } } diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/Kernel/Paragraphs/MediaParagraphsTest.php index 3b2899131..15c2774a3 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/Kernel/Paragraphs/MediaParagraphsTest.php @@ -40,7 +40,7 @@ class MediaParagraphsTest extends ParagraphsTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->container->get('module_handler')->loadInclude('oe_paragraphs_media_field_storage', 'install'); @@ -227,7 +227,7 @@ public function testTextWithMedia(): void { 'url' => 'https://www.youtube.com/watch?v=1-g73ty9v04', ], ])->toString(); - $this->assertContains($partial_iframe_url, $video_iframe->attr('src')); + $this->assertStringContainsString($partial_iframe_url, $video_iframe->attr('src')); // Create an avportal video and add it to the paragraph. $media = $media_storage->create([ @@ -355,14 +355,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered')); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered div.ecl-hero-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width')); // Render paragraph in Bulgarian. @@ -370,7 +370,7 @@ public function testBanner(): void { $crawler = new Crawler($html); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered div.ecl-hero-banner__image'); // Bulgarian media should be rendered. - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($bg_file->getFileUri()) . ')', $image_element->attr('style') ); @@ -406,14 +406,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image')); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image div.ecl-hero-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width')); // Variant - image / Modifier - page_center / Full width - No. @@ -425,14 +425,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image.ecl-page-banner--centered')); $image_element = $crawler->filter('section.ecl-page-banner.ecl-page-banner--image.ecl-page-banner--centered div.ecl-page-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width')); // Variant - image / Modifier - page_left / Full width - Yes. @@ -446,14 +446,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image.ecl-page-banner--full-width')); $image_element = $crawler->filter('section.ecl-page-banner.ecl-page-banner--image div.ecl-page-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - image-shade / Modifier - hero_center / Full width - Yes. $paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_image_shade'); @@ -465,14 +465,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered.ecl-hero-banner--full-width')); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--centered div.ecl-hero-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - image-shade / Modifier - hero_left / Full width - Yes. $paragraph->get('field_oe_banner_type')->setValue('hero_left'); @@ -484,14 +484,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade.ecl-hero-banner--full-width')); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image-shade div.ecl-hero-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - image-shade / Modifier - page_center / Full width - No. $paragraph->get('field_oe_banner_type')->setValue('page_center'); @@ -503,14 +503,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image-shade.ecl-page-banner--centered')); $image_element = $crawler->filter('section.ecl-page-banner.ecl-page-banner--image-shade.ecl-page-banner--centered div.ecl-page-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width')); // Variant - image-shade / Modifier - page_left / Full width - No. @@ -523,14 +523,14 @@ public function testBanner(): void { $this->assertCount(1, $crawler->filter('section.ecl-page-banner.ecl-page-banner--image-shade')); $image_element = $crawler->filter('section.ecl-page-banner.ecl-page-banner--image-shade div.ecl-page-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . file_create_url($en_file->getFileUri()) . ')', $image_element->attr('style') ); $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width')); // Variant - default / Modifier - hero_center / Full width - No. @@ -551,7 +551,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-hero-banner--full-width')); // Variant - default / Modifier - hero_left / Full width - Yes. @@ -573,7 +573,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - default / Modifier - page_center / Full width - Yes. $paragraph->get('field_oe_banner_type')->setValue('page_center'); @@ -592,7 +592,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - default / Modifier - page_left / Full width - Yes. $paragraph->get('field_oe_banner_type')->setValue('page_left'); @@ -612,7 +612,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - primary / Modifier - hero_center / Full width - Yes. $paragraph->get('oe_paragraphs_variant')->setValue('oe_banner_primary'); @@ -632,7 +632,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - primary / Modifier - hero_left / Full width - Yes. $paragraph->get('field_oe_banner_type')->setValue('hero_left'); @@ -652,7 +652,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-hero-banner__content div.ecl-hero-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-hero-banner__content p.ecl-hero-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-hero-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - primary / Modifier - page_center / Full width - Yes. $paragraph->get('field_oe_banner_type')->setValue('page_center'); @@ -671,7 +671,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); // Variant - primary / Modifier - page_left / Full width - No. $paragraph->get('field_oe_banner_type')->setValue('page_left'); @@ -692,7 +692,7 @@ public function testBanner(): void { $this->assertEquals('Banner', trim($crawler->filter('div.ecl-page-banner__content div.ecl-page-banner__title')->text())); $this->assertEquals('Description', trim($crawler->filter('div.ecl-page-banner__content p.ecl-page-banner__description')->text())); $this->assertCount(1, $crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after')); - $this->assertContains('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); + $this->assertStringContainsString('Example', trim($crawler->filter('div.ecl-page-banner__content a.ecl-link.ecl-link--cta.ecl-link--icon.ecl-link--icon-after span.ecl-link__label')->text())); $this->assertCount(0, $crawler->filter('.ecl-page-banner--full-width')); // Create a media using AV Portal image and add it to the paragraph. @@ -724,7 +724,7 @@ public function testBanner(): void { $this->assertCount(0, $crawler->filter('div.ecl-page-banner__content a.ecl-link')); $image_element = $crawler->filter('section.ecl-hero-banner.ecl-hero-banner--image.ecl-hero-banner--centered div.ecl-hero-banner__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( 'url(' . (file_create_url('avportal://P-038924/00-15.jpg')) . ')', $image_element->attr('style') ); @@ -765,9 +765,9 @@ public function testIframe(): void { // Assert unpublished media isn't shown. $html = $this->renderParagraph($paragraph); - $this->assertNotContains('figure', $html); - $this->assertNotContains('http://example.com/iframe', $html); - $this->assertNotContains('ecl-u-type-heading-2', $html); + $this->assertStringNotContainsString('figure', $html); + $this->assertStringNotContainsString('http://example.com/iframe', $html); + $this->assertStringNotContainsString('ecl-u-type-heading-2', $html); // Publish media. $media->setPublished()->save(); @@ -777,22 +777,22 @@ public function testIframe(): void { $html = $this->renderParagraph($paragraph); $crawler = new Crawler($html); $iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--custom-ratio div.ecl-media-container__media.ecl-media-container__media--ratio-custom iframe'); - $this->assertContains('http://example.com/iframe', $iframe->attr('src')); - $this->assertNotContains('ecl-u-type-heading-2', $html); + $this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src')); + $this->assertStringNotContainsString('ecl-u-type-heading-2', $html); // Assert "Full width" field. $paragraph->set('field_oe_iframe_media_full_width', TRUE)->save(); $html = $this->renderParagraph($paragraph); $crawler = new Crawler($html); $iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--fullwidth.ecl-media-container--custom-ratio div.ecl-media-container__media.ecl-media-container__media--ratio-custom iframe'); - $this->assertContains('http://example.com/iframe', $iframe->attr('src')); + $this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src')); // Assert ratio. $media->set('oe_media_iframe_ratio', '1_1')->save(); $html = $this->renderParagraph($paragraph); $crawler = new Crawler($html); $iframe = $crawler->filter('figure.ecl-media-container.ecl-media-container--fullwidth div.ecl-media-container__media.ecl-media-container__media--ratio-1-1 iframe'); - $this->assertContains('http://example.com/iframe', $iframe->attr('src')); + $this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src')); // Assert title and full width. $paragraph->set('field_oe_title', 'Iframe paragraph title'); @@ -800,9 +800,9 @@ public function testIframe(): void { $html = $this->renderParagraph($paragraph); $crawler = new Crawler($html); $title = $crawler->filter('h2.ecl-u-type-heading-2', $html); - $this->assertContains('Iframe paragraph title', $title->text()); + $this->assertStringContainsString('Iframe paragraph title', $title->text()); $iframe = $crawler->filter('figure.ecl-media-container div.ecl-media-container__media.ecl-media-container__media--ratio-1-1 iframe'); - $this->assertContains('http://example.com/iframe', $iframe->attr('src')); + $this->assertStringContainsString('http://example.com/iframe', $iframe->attr('src')); // Translate the media to Bulgarian. $media_bg = $media->addTranslation('bg', [ @@ -818,9 +818,9 @@ public function testIframe(): void { $html = $this->renderParagraph($paragraph, 'bg'); $crawler = new Crawler($html); $title = $crawler->filter('h2.ecl-u-type-heading-2', $html); - $this->assertContains('Iframe paragraph title bg', $title->text()); + $this->assertStringContainsString('Iframe paragraph title bg', $title->text()); $iframe = $crawler->filter('figure.ecl-media-container div.ecl-media-container__media.ecl-media-container__media--ratio-1-1 iframe'); - $this->assertContains('http://example.com/iframe_bg', $iframe->attr('src')); + $this->assertStringContainsString('http://example.com/iframe_bg', $iframe->attr('src')); } } diff --git a/tests/Kernel/Paragraphs/ParagraphsTest.php b/tests/Kernel/Paragraphs/ParagraphsTest.php index e0d7796b0..147aa4b44 100644 --- a/tests/Kernel/Paragraphs/ParagraphsTest.php +++ b/tests/Kernel/Paragraphs/ParagraphsTest.php @@ -216,7 +216,7 @@ public function testListItem(): void { $image_element = $crawler->filter('article.ecl-card div.ecl-card__image'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( file_url_transform_relative(file_create_url($image->getFileUri())), $image_element->attr('style') ); @@ -269,7 +269,7 @@ public function testListItem(): void { $this->assertCount(0, $crawler->filter('article.ecl-content-item > div.ecl-content-item__image__after')); $image_element = $crawler->filter('article.ecl-content-item > div[role="img"].ecl-u-d-l-block'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( file_url_transform_relative(file_create_url($image->getFileUri())), $image_element->attr('style') ); @@ -303,7 +303,7 @@ public function testListItem(): void { $this->assertCount(1, $crawler->filter('article.ecl-content-item > div.ecl-content-item__image__after')); $image_element = $crawler->filter('article.ecl-content-item > div[role="img"].ecl-u-d-l-block'); $this->assertCount(1, $image_element); - $this->assertContains( + $this->assertStringContainsString( file_url_transform_relative(file_create_url($image->getFileUri())), $image_element->attr('style') ); diff --git a/tests/Kernel/Paragraphs/ParagraphsTestBase.php b/tests/Kernel/Paragraphs/ParagraphsTestBase.php index 34c44dae4..7ed34efc8 100644 --- a/tests/Kernel/Paragraphs/ParagraphsTestBase.php +++ b/tests/Kernel/Paragraphs/ParagraphsTestBase.php @@ -41,7 +41,7 @@ abstract class ParagraphsTestBase extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('paragraph'); diff --git a/tests/Kernel/Paragraphs/SocialMediaFollowTest.php b/tests/Kernel/Paragraphs/SocialMediaFollowTest.php index c4b301718..066531bde 100644 --- a/tests/Kernel/Paragraphs/SocialMediaFollowTest.php +++ b/tests/Kernel/Paragraphs/SocialMediaFollowTest.php @@ -53,34 +53,34 @@ public function testRendering(): void { // Verify that the paragraph contains all the links. $links_html = $links->html(); - $this->assertContains('Email', $links_html); + $this->assertStringContainsString('Email', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 5) = \'#email\']')); // Assert that the Facebook link is rendered but not the Facebook icon, as // this link has no type associated. - $this->assertContains('Facebook', $links_html); + $this->assertStringContainsString('Facebook', $links_html); $this->assertCount(0, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 8) = \'#facebook\']')); - $this->assertContains('Flickr', $links_html); + $this->assertStringContainsString('Flickr', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#flickr\']')); - $this->assertContains('Google+', $links_html); + $this->assertStringContainsString('Google+', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#google\']')); - $this->assertContains('Instagram', $links_html); + $this->assertStringContainsString('Instagram', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 9) = \'#instagram\']')); - $this->assertContains('LinkedIn', $links_html); + $this->assertStringContainsString('LinkedIn', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 8) = \'#linkedin\']')); - $this->assertContains('Pinterest', $links_html); + $this->assertStringContainsString('Pinterest', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 9) = \'#pinterest\']')); - $this->assertContains('RSS', $links_html); + $this->assertStringContainsString('RSS', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 3) = \'#rss\']')); - $this->assertContains('Storify', $links_html); + $this->assertStringContainsString('Storify', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#storify\']')); - $this->assertContains('1st Twitter', $links_html); - $this->assertContains('2nd Twitter', $links_html); + $this->assertStringContainsString('1st Twitter', $links_html); + $this->assertStringContainsString('2nd Twitter', $links_html); $this->assertCount(2, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#twitter\']')); - $this->assertContains('Yammer', $links_html); + $this->assertStringContainsString('Yammer', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 6) = \'#yammer\']')); - $this->assertContains('Youtube', $links_html); + $this->assertStringContainsString('Youtube', $links_html); $this->assertCount(1, $crawler->filterXPath('//*[name()=\'use\' and substring(@*, string-length(@*) - 7) = \'#youtube\']')); - $this->assertContains('Other social networks', $links_html); + $this->assertStringContainsString('Other social networks', $links_html); // Fix the Facebook link type. $paragraph->get('field_oe_social_media_links')->get(1)->set('link_type', 'facebook'); diff --git a/tests/Kernel/Paragraphs/TimelineParagraphTest.php b/tests/Kernel/Paragraphs/TimelineParagraphTest.php index ff957d007..ae3ddaf35 100644 --- a/tests/Kernel/Paragraphs/TimelineParagraphTest.php +++ b/tests/Kernel/Paragraphs/TimelineParagraphTest.php @@ -27,7 +27,7 @@ class TimelineParagraphTest extends ParagraphsTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig([ diff --git a/tests/Kernel/Patterns/FilePatternRenderingTest.php b/tests/Kernel/Patterns/FilePatternRenderingTest.php index 28a7dbd57..1277bbcf7 100644 --- a/tests/Kernel/Patterns/FilePatternRenderingTest.php +++ b/tests/Kernel/Patterns/FilePatternRenderingTest.php @@ -26,7 +26,7 @@ class FilePatternRenderingTest extends AbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('file'); $this->installSchema('file', ['file_usage']); diff --git a/tests/Kernel/PersonRenderTest.php b/tests/Kernel/PersonRenderTest.php index 60593f683..42931b384 100644 --- a/tests/Kernel/PersonRenderTest.php +++ b/tests/Kernel/PersonRenderTest.php @@ -72,9 +72,9 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); module_load_include('install', 'oe_content_person'); - oe_content_person_install(); + oe_content_person_install(FALSE); $this->setUpCurrentUser([], [], TRUE); } diff --git a/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php b/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php index 26b168406..9403e10c0 100644 --- a/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php +++ b/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php @@ -30,9 +30,9 @@ public function testCondition(): void { 'negate' => TRUE, ]); - $this->assertEqual($condition->summary(), new FormattableMarkup('The current component library is @component_library', ['@component_library' => 'ec'])); - $this->assertEqual($condition_empty->summary(), new FormattableMarkup('The current component library can be set to anything', [])); - $this->assertEqual($condition_negated->summary(), new FormattableMarkup('The current component library is not @component_library', ['@component_library' => 'ec'])); + $this->assertEquals(new FormattableMarkup('The current component library is @component_library', ['@component_library' => 'ec']), $condition->summary()); + $this->assertEquals(new FormattableMarkup('The current component library can be set to anything', []), $condition_empty->summary()); + $this->assertEquals(new FormattableMarkup('The current component library is not @component_library', ['@component_library' => 'ec']), $condition_negated->summary()); // Assert condition values, by default the component library set to "ec". $this->assertTrue($condition->execute(), 'Condition asserting that component library is "ec" should be true.'); diff --git a/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php b/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php index c800a6505..2dc7cd540 100644 --- a/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php +++ b/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php @@ -30,9 +30,9 @@ public function testCondition(): void { 'negate' => TRUE, ]); - $this->assertEqual($condition->summary(), new FormattableMarkup('The current ECL branding is @branding', ['@branding' => 'standardised'])); - $this->assertEqual($condition_empty->summary(), new FormattableMarkup('The current ECL branding can be set to anything', [])); - $this->assertEqual($condition_negated->summary(), new FormattableMarkup('The current ECL branding is not @branding', ['@branding' => 'standardised'])); + $this->assertEquals(new FormattableMarkup('The current ECL branding is @branding', ['@branding' => 'standardised']), $condition->summary()); + $this->assertEquals(new FormattableMarkup('The current ECL branding can be set to anything', []), $condition_empty->summary()); + $this->assertEquals(new FormattableMarkup('The current ECL branding is not @branding', ['@branding' => 'standardised']), $condition_negated->summary()); // Assert condition values, by default ECL branding set to "Standardised". $this->assertFalse($condition->execute(), 'Condition asserting that ECL branding is "standardised" should be false.'); diff --git a/tests/Kernel/ProjectRenderTest.php b/tests/Kernel/ProjectRenderTest.php index 70c034017..96d1a27d8 100644 --- a/tests/Kernel/ProjectRenderTest.php +++ b/tests/Kernel/ProjectRenderTest.php @@ -64,7 +64,7 @@ protected function setUp(): void { ]); module_load_include('install', 'oe_content'); - oe_content_install(); + oe_content_install(FALSE); // Set current user to UID 1, so that by default we can access everything. $account = User::load(1); diff --git a/tests/Kernel/RenderingTest.php b/tests/Kernel/RenderingTest.php index 1ff01f05f..3e724aa13 100644 --- a/tests/Kernel/RenderingTest.php +++ b/tests/Kernel/RenderingTest.php @@ -28,7 +28,7 @@ class RenderingTest extends AbstractKernelTestBase implements FormInterface { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installConfig('filter'); } diff --git a/tests/Kernel/StatusMessagesTest.php b/tests/Kernel/StatusMessagesTest.php index 7ebb0954c..eda4f4655 100644 --- a/tests/Kernel/StatusMessagesTest.php +++ b/tests/Kernel/StatusMessagesTest.php @@ -89,7 +89,7 @@ public function testStatusMessages(array $data): void { $wrapper, sprintf('No messages of type "%s" were expected, but %d found.', $type, $wrapper->count()) ); - $this->assertNotContains( + $this->assertStringNotContainsString( $info['heading'], $html, 'No messages of type "%s" are present, but the related heading "%s" was found.', $type, $info['heading'] diff --git a/tests/Kernel/TimelineTest.php b/tests/Kernel/TimelineTest.php index 548ea9db0..ca21e2d97 100644 --- a/tests/Kernel/TimelineTest.php +++ b/tests/Kernel/TimelineTest.php @@ -84,7 +84,7 @@ protected function setUp(): void { $this->installEntitySchema('skos_concept_scheme'); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Create content type. @@ -199,8 +199,8 @@ public function testTimelineRender(): void { $build = $display->build($node); $output = $this->renderRoot($build); - $this->assertNotContains('.ecl-timeline__item--toggle', (string) $output); - $this->assertNotContains('.ecl-timeline__item--collapsed', (string) $output); + $this->assertStringNotContainsString('.ecl-timeline__item--toggle', (string) $output); + $this->assertStringNotContainsString('.ecl-timeline__item--collapsed', (string) $output); } } diff --git a/tests/Kernel/ValueObject/DateTimeRangeTest.php b/tests/Kernel/ValueObject/DateTimeRangeTest.php index ce7705a59..ff1e37d60 100644 --- a/tests/Kernel/ValueObject/DateTimeRangeTest.php +++ b/tests/Kernel/ValueObject/DateTimeRangeTest.php @@ -37,7 +37,7 @@ class DateTimeRangeTest extends DateTimeTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // Add a datetime range field. diff --git a/tests/Kernel/ValueObject/DateTimeTest.php b/tests/Kernel/ValueObject/DateTimeTest.php index f1bd1038d..42943701b 100644 --- a/tests/Kernel/ValueObject/DateTimeTest.php +++ b/tests/Kernel/ValueObject/DateTimeTest.php @@ -37,7 +37,7 @@ class DateTimeTest extends DateTimeTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); // Create a field with settings to validate. diff --git a/tests/Kernel/ValueObject/DateTimeTestBase.php b/tests/Kernel/ValueObject/DateTimeTestBase.php index b154307b0..063f3e055 100644 --- a/tests/Kernel/ValueObject/DateTimeTestBase.php +++ b/tests/Kernel/ValueObject/DateTimeTestBase.php @@ -31,11 +31,11 @@ abstract class DateTimeTestBase extends FieldKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + \Drupal::configFactory()->getEditable('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); $this->installConfig(['image', 'responsive_image']); } diff --git a/tests/Kernel/ValueObject/ImageTest.php b/tests/Kernel/ValueObject/ImageTest.php index a2cc9bf8f..7d98be961 100644 --- a/tests/Kernel/ValueObject/ImageTest.php +++ b/tests/Kernel/ValueObject/ImageTest.php @@ -32,7 +32,7 @@ class ImageTest extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('file'); @@ -89,10 +89,11 @@ public function testFromStyledImageItem() { $object = ImageValueObject::fromStyledImageItem($entity->get('field_image')->first(), $style->getName()); $this->assertEquals($title, $object->getName()); $this->assertEquals($alt, $object->getAlt()); - $this->assertContains('/styles/main_style/public/example_1.jpg', $object->getSource()); + $this->assertStringContainsString('/styles/main_style/public/example_1.jpg', $object->getSource()); $invalid_image_style = $this->randomMachineName(); - $this->setExpectedException(\InvalidArgumentException::class, sprintf('Could not load image style with name "%s".', $invalid_image_style)); + $this->expectException('InvalidArgumentException'); + $this->expectExceptionMessage(sprintf('Could not load image style with name "%s".', $invalid_image_style)); ImageValueObject::fromStyledImageItem($entity->get('field_image')->first(), $invalid_image_style); } diff --git a/tests/Kernel/Webtools/SocialShareTest.php b/tests/Kernel/Webtools/SocialShareTest.php index 6cecbc1d9..3b6a92970 100644 --- a/tests/Kernel/Webtools/SocialShareTest.php +++ b/tests/Kernel/Webtools/SocialShareTest.php @@ -42,7 +42,7 @@ public function testSocialShareBlockRendering(): void { // Make sure that social media share block is correctly rendered. $custom_footer = $crawler->filter('p.ecl-social-media-share__description'); - $this->assertContains('Share this page', $custom_footer->html()); + $this->assertStringContainsString('Share this page', $custom_footer->html()); $this->assertCount(1, $custom_footer); } diff --git a/tests/PatternAssertions/BasePatternAssert.php b/tests/PatternAssertions/BasePatternAssert.php index 1a7236b1d..5143ba0b7 100644 --- a/tests/PatternAssertions/BasePatternAssert.php +++ b/tests/PatternAssertions/BasePatternAssert.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\oe_theme\PatternAssertions; +use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\Assert; use PHPUnit\Framework\Exception; use Symfony\Component\DomCrawler\Crawler; @@ -13,6 +14,8 @@ */ abstract class BasePatternAssert extends Assert implements PatternAssertInterface { + use PhpUnitCompatibilityTrait; + /** * Method that returns the assertions to be run by a particular pattern. * @@ -195,7 +198,7 @@ protected function assertImage(?array $expected_image, string $selector, Crawler $this->assertElementExists($selector, $crawler); $element = $crawler->filter($selector); self::assertEquals($expected_image['alt'], $element->attr('alt')); - self::assertContains($expected_image['src'], $element->attr('src')); + self::assertStringContainsString($expected_image['src'], $element->attr('src')); } } diff --git a/tests/PatternAssertions/FeaturedItemAssert.php b/tests/PatternAssertions/FeaturedItemAssert.php index 5b50d145e..1d47b7fa5 100644 --- a/tests/PatternAssertions/FeaturedItemAssert.php +++ b/tests/PatternAssertions/FeaturedItemAssert.php @@ -70,7 +70,7 @@ protected function assertFeaturedItemImage($expected_image, string $variant, Cra } $image_div = $crawler->filter($image_div_selector); self::assertEquals($expected_image['alt'], $image_div->attr('aria-label')); - self::assertContains($expected_image['src'], $image_div->attr('style')); + self::assertStringContainsString($expected_image['src'], $image_div->attr('style')); } /** @@ -108,7 +108,7 @@ protected function assertFooterItems($expected_info_items, Crawler $crawler): vo foreach ($expected_info_items as $index => $expected_info_item) { $info_element = $info_elements->eq($index); $icon_element = $info_element->filter('svg.ecl-icon.ecl-icon--xs use'); - $this::assertContains('#' . $expected_info_item['icon'], $icon_element->attr('xlink:href')); + $this::assertStringContainsString('#' . $expected_info_item['icon'], $icon_element->attr('xlink:href')); $this->assertElementText($expected_info_item['text'], 'span.ecl-card__info-label', $info_element); } } diff --git a/tests/PatternAssertions/FileAssert.php b/tests/PatternAssertions/FileAssert.php index 6b8e1242e..cb5cc5057 100644 --- a/tests/PatternAssertions/FileAssert.php +++ b/tests/PatternAssertions/FileAssert.php @@ -52,7 +52,7 @@ protected function assertFile(array $expected_file, Crawler $crawler): void { // Assert icon. $icon = $crawler->filter('div.ecl-file div.ecl-file__container svg.ecl-file__icon use'); - self::assertContains($expected_file['icon'], $icon->attr('xlink:href')); + self::assertStringContainsString($expected_file['icon'], $icon->attr('xlink:href')); } } diff --git a/tests/PatternAssertions/IconsTextAssert.php b/tests/PatternAssertions/IconsTextAssert.php index 6cce85159..ec7544729 100644 --- a/tests/PatternAssertions/IconsTextAssert.php +++ b/tests/PatternAssertions/IconsTextAssert.php @@ -48,7 +48,7 @@ protected function assertItems(array $expected_items, Crawler $crawler): void { $list_element = $list_elements->eq($index); self::assertEquals($expected_item['text'], trim($list_element->text())); $icon_element = $list_element->filter('svg.ecl-icon.ecl-icon--m.ecl-u-mr-s use'); - $this::assertContains($expected_item['icon'], $icon_element->attr('xlink:href')); + $this::assertStringContainsString($expected_item['icon'], $icon_element->attr('xlink:href')); } } diff --git a/tests/PatternAssertions/ListItemAssert.php b/tests/PatternAssertions/ListItemAssert.php index 3bedc2a78..c2f21431f 100644 --- a/tests/PatternAssertions/ListItemAssert.php +++ b/tests/PatternAssertions/ListItemAssert.php @@ -190,7 +190,7 @@ protected function assertThumbnailImage($expected_image, string $variant, Crawle $this->assertElementExists($image_div_selector, $crawler); $image_div = $crawler->filter($image_div_selector); self::assertEquals($expected_image['alt'], $image_div->attr('aria-label')); - self::assertContains($expected_image['src'], $image_div->attr('style')); + self::assertStringContainsString($expected_image['src'], $image_div->attr('style')); } /** @@ -206,7 +206,7 @@ protected function assertThumbnailImage($expected_image, string $variant, Crawle protected function assertHighlightImage($expected_image, string $variant, Crawler $crawler): void { $image_div = $crawler->filter('article.ecl-card header.ecl-card__header div.ecl-card__image'); self::assertEquals($expected_image['alt'], $image_div->attr('aria-label')); - self::assertContains($expected_image['src'], $image_div->attr('style')); + self::assertStringContainsString($expected_image['src'], $image_div->attr('style')); } /** diff --git a/tests/PatternAssertions/SocialMediaLinksAssert.php b/tests/PatternAssertions/SocialMediaLinksAssert.php index 7b52d9f83..ca9147b0d 100644 --- a/tests/PatternAssertions/SocialMediaLinksAssert.php +++ b/tests/PatternAssertions/SocialMediaLinksAssert.php @@ -94,9 +94,9 @@ protected function assertLinks(array $expected_items, Crawler $crawler): void { $link_element = $li_item->filter('a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-before.ecl-social-media-follow__link'); $label_element = $link_element->filter('span.ecl-link__label'); $svg = $link_element->filter('svg.ecl-icon.ecl-icon--xl.ecl-link__icon.ecl-social-media-follow__icon use'); - self::assertContains('icons-social.svg#' . $expected_item['service'], $svg->attr('xlink:href')); + self::assertStringContainsString('icons-social.svg#' . $expected_item['service'], $svg->attr('xlink:href')); $svg_hover = $link_element->filter('svg.ecl-icon.ecl-icon--xl.ecl-link__icon.ecl-social-media-follow__icon-hover use'); - self::assertContains('icons-social.svg#' . $expected_item['service'] . '_hover', $svg_hover->attr('xlink:href')); + self::assertStringContainsString('icons-social.svg#' . $expected_item['service'] . '_hover', $svg_hover->attr('xlink:href')); } self::assertEquals($expected_item['label'], trim($label_element->text())); diff --git a/tests/Traits/RenderTrait.php b/tests/Traits/RenderTrait.php index 617a5d14b..5b7cb8b2e 100644 --- a/tests/Traits/RenderTrait.php +++ b/tests/Traits/RenderTrait.php @@ -48,7 +48,7 @@ protected function assertRendering(string $html, array $assertions): void { if (isset($assertions['contains'])) { foreach ($assertions['contains'] as $string) { $message = "String '{$string}' not found in:" . PHP_EOL . $html; - $this->assertContains($string, $html, $message); + $this->assertStringContainsString($string, $html, $message); } } diff --git a/tests/Unit/ValueObject/ImageValueObjectTest.php b/tests/Unit/ValueObject/ImageValueObjectTest.php index c6d07c300..a8f39fb6c 100644 --- a/tests/Unit/ValueObject/ImageValueObjectTest.php +++ b/tests/Unit/ValueObject/ImageValueObjectTest.php @@ -57,7 +57,7 @@ class ImageValueObjectTest extends UnitTestCase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->imageUri = $this->prophesize(FieldItemList::class); @@ -161,7 +161,7 @@ function file_create_url($uri): string { * Processed url. */ function file_create_url($uri): string { - return \Drupal\Tests\oe_theme\Unit\Patterns\file_create_url($uri); + return $uri; } } diff --git a/tests/modules/oe_theme_js_test/oe_theme_js_test.info.yml b/tests/modules/oe_theme_js_test/oe_theme_js_test.info.yml index 1c193f1bc..80c6175ed 100644 --- a/tests/modules/oe_theme_js_test/oe_theme_js_test.info.yml +++ b/tests/modules/oe_theme_js_test/oe_theme_js_test.info.yml @@ -1,5 +1,5 @@ name: 'OpenEuropa Theme Javascript Test' description: 'Support module for Javascript related tests.' type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 package: Testing diff --git a/tests/modules/oe_theme_patterns_render_test/oe_theme_patterns_render_test.info.yml b/tests/modules/oe_theme_patterns_render_test/oe_theme_patterns_render_test.info.yml index c1305a9cb..29a435e97 100644 --- a/tests/modules/oe_theme_patterns_render_test/oe_theme_patterns_render_test.info.yml +++ b/tests/modules/oe_theme_patterns_render_test/oe_theme_patterns_render_test.info.yml @@ -1,3 +1,3 @@ name: 'OpenEuropa Theme patterns render test' type: module -core: 8.x +core_version_requirement: ^8.9 || ^9.1 From 24c42279f131c7e76bf5c3e6d1175a68259bc66d Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Mon, 19 Jul 2021 17:00:34 +0300 Subject: [PATCH 02/28] OEL-60: Run Toolkit tests as kernel tests in Drupal 8.9. --- .../src/Functional/RetinaScaleEffectTest.php | 2 +- .../tests/src/Traits/ToolkitTestTrait.php | 134 ++++++++++++++++++ 2 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 modules/oe_theme_helper/tests/src/Traits/ToolkitTestTrait.php diff --git a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php index c7279a6a8..86873e37b 100644 --- a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php @@ -4,8 +4,8 @@ namespace Drupal\Tests\oe_theme_helper\Functional; +use Drupal\Tests\oe_theme_helper\Traits\ToolkitTestTrait; use Drupal\Tests\token\Kernel\KernelTestBase; -use Drupal\Tests\Traits\Core\Image\ToolkitTestTrait; /** * Tests that the Retina Scale effect upscales images appropriately. diff --git a/modules/oe_theme_helper/tests/src/Traits/ToolkitTestTrait.php b/modules/oe_theme_helper/tests/src/Traits/ToolkitTestTrait.php new file mode 100644 index 000000000..848f19173 --- /dev/null +++ b/modules/oe_theme_helper/tests/src/Traits/ToolkitTestTrait.php @@ -0,0 +1,134 @@ +=')) { + /** + * Wraps the Drupal 9 ToolkitTestTrait trait. + */ + trait ToolkitTestTrait { + + use \Drupal\Tests\Traits\Core\Image\ToolkitTestTrait; + + } +} +else { + /** + * Provides Drupal 8.9 Toolkit kernel tests backward compatibility layer. + * + * This trait is a copy of \Drupal\Tests\Traits\Core\Image\ToolkitTestTrait + * from Drupal >=9.1. + */ + trait ToolkitTestTrait { + + use TestFileCreationTrait { + getTestFiles as drupalGetTestFiles; + } + + /** + * Resets/initializes the history of calls to the test toolkit functions. + */ + protected function imageTestReset(): void { + \Drupal::state()->delete('image_test.results'); + } + + /** + * Asserts that all of the specified image operations are called once. + * + * @param string[] $expected + * Array containing the operation names, e.g. load, save, crop, etc. + */ + public function assertToolkitOperationsCalled(array $expected): void { + // If one of the image operations is expected, 'apply' should be expected + // as well. + $operations = [ + 'resize', + 'rotate', + 'crop', + 'desaturate', + 'create_new', + 'scale', + 'scale_and_crop', + 'my_operation', + 'convert', + ]; + if (count(array_intersect($expected, $operations)) > 0 && !in_array('apply', $expected)) { + $expected[] = 'apply'; + } + + // Determine which operations were called. + $actual = array_keys(array_filter($this->imageTestGetAllCalls())); + + // Determine if there were any expected that were not called. + $uncalled = array_diff($expected, $actual); + $this->assertEmpty($uncalled); + + // Determine if there were any unexpected calls. If all unexpected calls + // are operations and apply was expected, we do not count it as an error. + $unexpected = array_diff($actual, $expected); + $assert = !(count($unexpected) && (!in_array('apply', $expected) || count(array_intersect($unexpected, $operations)) !== count($unexpected))); + $this->assertTrue($assert); + } + + /** + * Gets an array of calls to the 'test' toolkit. + * + * @return array + * An array keyed by operation name ('parseFile', 'save', 'settings', + * 'resize', 'rotate', 'crop', 'desaturate') with values being arrays of + * parameters passed to each call. + */ + protected function imageTestGetAllCalls(): array { + return \Drupal::state()->get('image_test.results', []); + } + + /** + * Sets up an image with the custom toolkit. + * + * @return \Drupal\Core\Image\ImageInterface + * The image object. + */ + protected function getImage(): ImageInterface { + $image_factory = \Drupal::service('image.factory'); + $file = current($this->drupalGetTestFiles('image')); + $image = $image_factory->get($file->uri, 'test'); + $this->assertTrue($image->isValid()); + return $image; + } + + /** + * Asserts the effect processing of an image effect plugin. + * + * @param string[] $expected_operations + * String array containing the operation names, e.g. load, save, etc. + * @param string $effect_name + * The name of the image effect to test. + * @param array $data + * The data to be passed to the image effect. + */ + protected function assertImageEffect(array $expected_operations, string $effect_name, array $data): void { + $effect = $this->imageEffectPluginManager->createInstance($effect_name, ['data' => $data]); + $image = $this->getImage(); + $this->imageTestReset(); + $this->assertTrue($effect->applyEffect($image)); + $this->assertToolkitOperationsCalled($expected_operations); + } + + } +} From 9d95e7ff9aa8d6c8c7714ab3f0af2be90978ef70 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 19 Jul 2021 16:37:58 +0200 Subject: [PATCH 03/28] OEL-60: Class minor refactor. --- .../RetinaScaleEffectTest.php | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) rename modules/oe_theme_helper/tests/src/{Functional => Kernel}/RetinaScaleEffectTest.php (85%) diff --git a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php similarity index 85% rename from modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php rename to modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php index 86873e37b..0d38ebdd8 100644 --- a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php @@ -2,10 +2,10 @@ declare(strict_types = 1); -namespace Drupal\Tests\oe_theme_helper\Functional; +namespace Drupal\Tests\oe_theme_helper\Kernel; +use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\oe_theme_helper\Traits\ToolkitTestTrait; -use Drupal\Tests\token\Kernel\KernelTestBase; /** * Tests that the Retina Scale effect upscales images appropriately. @@ -27,10 +27,10 @@ class RetinaScaleEffectTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = [ + protected static $modules = [ 'image', - 'oe_theme_helper', 'image_test', + 'oe_theme_helper', 'system', ]; @@ -68,8 +68,8 @@ public function testRetinaScaleEffect(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals(10, $calls['scale'][0][0], 'Width was passed correctly'); - $this->assertEquals(10, $calls['scale'][0][1], 'Height was based off aspect ratio and passed correctly'); + $this->assertEquals(10, $calls['scale'][0][0]); + $this->assertEquals(10, $calls['scale'][0][1]); } /** @@ -84,7 +84,7 @@ public function testScaleEffectDefaultUpscaling(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals($this->image->getWidth() * 4, $calls['scale'][0][0], 'Width was passed correctly'); + $this->assertEquals($this->image->getWidth() * 4, $calls['scale'][0][0]); } /** @@ -98,7 +98,7 @@ public function testRetinaScaleEffectForcedUpscaling(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals($this->image->getWidth() * 2, $calls['scale'][0][0], 'Width is double the original size.'); + $this->assertEquals($this->image->getWidth() * 2, $calls['scale'][0][0], 'Width must be twice the original size.'); } /** @@ -113,7 +113,7 @@ public function testTripleMultiplierRetinaScaleEffect(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals($this->image->getWidth() * 3, $calls['scale'][0][0], 'Width is triple the original size.'); + $this->assertEquals($this->image->getWidth() * 3, $calls['scale'][0][0], 'Width is three times the original size.'); } /** @@ -131,7 +131,7 @@ public function testTripleMultiplierRetinaScaleEffect(): void { protected function assertImageEffect(array $operations, $effect_name, array $data): void { /** @var \Drupal\image\ImageEffectInterface $effect */ $effect = $this->manager->createInstance($effect_name, ['data' => $data]); - $this->assertTrue($effect->applyEffect($this->image), 'Function returned the expected value.'); + $this->assertTrue($effect->applyEffect($this->image)); } } From 0ba43073d5238d4369cea662fbe7372cf1d31b52 Mon Sep 17 00:00:00 2001 From: escuriola Date: Mon, 19 Jul 2021 16:58:06 +0200 Subject: [PATCH 04/28] OEL-60: Removing unuseful assert messages. --- .../tests/src/Kernel/RetinaScaleEffectTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php index 0d38ebdd8..12fc45f19 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php @@ -98,7 +98,7 @@ public function testRetinaScaleEffectForcedUpscaling(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals($this->image->getWidth() * 2, $calls['scale'][0][0], 'Width must be twice the original size.'); + $this->assertEquals($this->image->getWidth() * 2, $calls['scale'][0][0]); } /** @@ -113,7 +113,7 @@ public function testTripleMultiplierRetinaScaleEffect(): void { $this->assertToolkitOperationsCalled(['scale']); $calls = $this->imageTestGetAllCalls(); - $this->assertEquals($this->image->getWidth() * 3, $calls['scale'][0][0], 'Width is three times the original size.'); + $this->assertEquals($this->image->getWidth() * 3, $calls['scale'][0][0]); } /** From 97d7454d0089ecc248b2486dc745bfb59c7626d4 Mon Sep 17 00:00:00 2001 From: escuriola Date: Tue, 20 Jul 2021 13:52:29 +0200 Subject: [PATCH 05/28] OEL-60: Changes to review and improve code format. --- composer.json | 3 ++- .../tests/src/Kernel/RetinaScaleEffectTest.php | 5 +++-- tests/Kernel/ValueObject/ImageTest.php | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index b9bf9a651..e226aa526 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "prefer-stable": true, "require": { "php": ">=7.3", - "drupal/core": "^8.9.16 ||^9.1", + "drupal/core": "^8.9.16 || ^9.1", "drupal/smart_trim": "^1.3", "drupal/twig_field_value": "^2.0", "drupal/ui_patterns": "^1.2", @@ -63,6 +63,7 @@ "_readme": [ "We explicitly require consolidation/robo to allow lower 'composer update --prefer-lowest' to complete successfully.", "We explicitly require consolidation/annotated-command to allow lower 'composer update --prefer-lowest' to complete successfully.", + "We explicity require drupal/core to allow lower 'composer update --prefer-lowest' to complete successfully.", "openeuropa/oe_search is used from a branch because of major upgrading is pending. Change again when it released.", "openeuropa/ecl-twig-loader is used from a branch because it must be upgrade to be D9 compatible. Change again when it released.", "openeuropa/oe_multilingual is used from a branch because it was an issue with D9. Change again when it released." diff --git a/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php index 12fc45f19..d6b9510c1 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php @@ -12,9 +12,10 @@ * * @group image * - * @group batch3 + * @group batch2 */ class RetinaScaleEffectTest extends KernelTestBase { + use ToolkitTestTrait; /** @@ -128,7 +129,7 @@ public function testTripleMultiplierRetinaScaleEffect(): void { * * @throws \Drupal\Component\Plugin\Exception\PluginException */ - protected function assertImageEffect(array $operations, $effect_name, array $data): void { + protected function assertImageEffect(array $operations, string $effect_name, array $data): void { /** @var \Drupal\image\ImageEffectInterface $effect */ $effect = $this->manager->createInstance($effect_name, ['data' => $data]); $this->assertTrue($effect->applyEffect($this->image)); diff --git a/tests/Kernel/ValueObject/ImageTest.php b/tests/Kernel/ValueObject/ImageTest.php index 7d98be961..717dc1837 100644 --- a/tests/Kernel/ValueObject/ImageTest.php +++ b/tests/Kernel/ValueObject/ImageTest.php @@ -92,8 +92,7 @@ public function testFromStyledImageItem() { $this->assertStringContainsString('/styles/main_style/public/example_1.jpg', $object->getSource()); $invalid_image_style = $this->randomMachineName(); - $this->expectException('InvalidArgumentException'); - $this->expectExceptionMessage(sprintf('Could not load image style with name "%s".', $invalid_image_style)); + $this->expectExceptionObject(new \InvalidArgumentException(sprintf('Could not load image style with name "%s".', $invalid_image_style))); ImageValueObject::fromStyledImageItem($entity->get('field_image')->first(), $invalid_image_style); } From 90bdc38e0f6129fc9219166cff791a2fe0a55739 Mon Sep 17 00:00:00 2001 From: escuriola Date: Thu, 22 Jul 2021 12:19:16 +0200 Subject: [PATCH 06/28] OEL-60: Change oe_multilingual required dependency to another branch. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e226aa526..5a98a5919 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ "We explicity require drupal/core to allow lower 'composer update --prefer-lowest' to complete successfully.", "openeuropa/oe_search is used from a branch because of major upgrading is pending. Change again when it released.", "openeuropa/ecl-twig-loader is used from a branch because it must be upgrade to be D9 compatible. Change again when it released.", - "openeuropa/oe_multilingual is used from a branch because it was an issue with D9. Change again when it released." + "openeuropa/oe_multilingual is used from a branch because it has an issue with D9. Change again when it released." ], "conflict": { "openeuropa/oe_corporate_blocks": "<3.0.0", From 08f2a0c3d86685e8e961e8f62cfbed31e75266e6 Mon Sep 17 00:00:00 2001 From: Abel Santos Corral Date: Tue, 3 Aug 2021 16:27:08 +0200 Subject: [PATCH 07/28] OEL-60: Add reference to OEL-337 branch for ecl-twig-loader at composer.json file. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5a98a5919..34420c303 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "drupal/smart_trim": "^1.3", "drupal/twig_field_value": "^2.0", "drupal/ui_patterns": "^1.2", - "openeuropa/ecl-twig-loader": "3.x-dev", + "openeuropa/ecl-twig-loader": "dev-OEL-337", "openeuropa/oe_time_caching": "dev-master", "ralouphie/mimey": "^2.1" }, From c462a4ae39c2aa1e59f5866b4803b5a2c6f1d193 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 17 Aug 2021 12:09:20 +0300 Subject: [PATCH 08/28] OEL-60: Move tests to tests/src folder. --- composer.json | 42 +++++++++---------- .../InPageNavigationBlockTest.php | 2 +- .../InPageNavigationLibraryTest.php | 2 +- tests/{ => src}/Behat/CleanupContext.php | 0 tests/{ => src}/Behat/DrupalContext.php | 0 tests/{ => src}/Behat/EventContext.php | 0 tests/{ => src}/Behat/MinkContext.php | 0 tests/{ => src}/Behat/OeThemeTestContext.php | 0 .../PreserveAnonymousPermissionsContext.php | 0 tests/{ => src}/Behat/Traits/UtilityTrait.php | 0 .../EnsurePHPUnitBatchingTestListener.php | 0 tests/{ => src}/Functional/BreadcrumbTest.php | 6 --- .../Functional/ConfigurationTest.php | 6 +-- .../ContentCallForProposalsRenderTest.php | 6 --- .../ContentCallForTendersRenderTest.php | 5 --- .../ContentConsultationRenderTest.php | 5 --- .../Functional/ContentEventRenderTest.php | 5 --- .../Functional/ContentNewsRenderTest.php | 5 --- .../ContentOrganisationRenderTest.php | 5 --- .../Functional/ContentPersonRenderTest.php | 5 --- .../Functional/ContentProjectRenderTest.php | 5 --- .../ContentPublicationRenderTest.php | 5 --- .../Functional/ContentRenderTestBase.php | 0 .../Functional/CorporateFooterRenderTest.php | 4 +- tests/{ => src}/Functional/ParagraphsTest.php | 0 .../Functional/fixtures/ec_footer.yml | 0 .../Functional/fixtures/eu_footer.yml | 0 .../JavascriptBehavioursTest.php | 2 +- .../Kernel/AbstractKernelTestBase.php | 13 +++++- tests/{ => src}/Kernel/BlockTest.php | 2 +- tests/{ => src}/Kernel/BreadcrumbTest.php | 2 +- .../Kernel/CallForProposalsRenderTest.php | 0 .../Kernel/CallForTendersRenderTest.php | 0 .../Kernel/ConsultationRenderTest.php | 0 .../Kernel/ContactFormRenderTest.php | 2 +- tests/{ => src}/Kernel/ContactRenderTest.php | 0 .../Kernel/ContentLanguageSwitcherTest.php | 2 +- .../Kernel/ContentRenderTestBase.php | 0 tests/{ => src}/Kernel/EventRenderTest.php | 0 .../{ => src}/Kernel/LanguageSwitcherTest.php | 0 .../Kernel/LegacyContentRenderTest.php | 0 tests/{ => src}/Kernel/MainMenuTest.php | 0 tests/{ => src}/Kernel/MediaRenderTest.php | 0 tests/{ => src}/Kernel/MenuLocalTasksTest.php | 0 .../MultilingualAbstractKernelTestBase.php | 0 tests/{ => src}/Kernel/NewsRenderTest.php | 0 .../Kernel/OrganisationRenderTest.php | 0 tests/{ => src}/Kernel/PagerTest.php | 0 .../Paragraphs/ContactParagraphTest.php | 0 .../Kernel/Paragraphs/ContentRowTest.php | 0 .../Kernel/Paragraphs/MediaParagraphsTest.php | 0 .../Kernel/Paragraphs/ParagraphsTest.php | 0 .../Kernel/Paragraphs/ParagraphsTestBase.php | 0 .../Paragraphs/SocialMediaFollowTest.php | 0 .../Paragraphs/TimelineParagraphTest.php | 0 .../DateBlockPatternRenderingTest.php | 0 .../Patterns/FilePatternRenderingTest.php | 0 .../Patterns/LinkPatternRenderingTest.php | 0 ...OrganisationTeaserPatternRenderingTest.php | 0 .../Patterns/PageHeaderRenderingTest.php | 0 tests/{ => src}/Kernel/PersonRenderTest.php | 0 .../CurrentComponentLibraryConditionTest.php | 0 .../CurrentEclBrandingConditionTest.php | 0 tests/{ => src}/Kernel/ProjectRenderTest.php | 0 .../Kernel/PublicationRenderTest.php | 0 tests/{ => src}/Kernel/RenderingTest.php | 0 .../{ => src}/Kernel/SearchFormBlockTest.php | 0 tests/{ => src}/Kernel/StatusMessagesTest.php | 0 tests/{ => src}/Kernel/TablesTest.php | 0 tests/{ => src}/Kernel/TimelineTest.php | 2 +- .../Kernel/ValueObject/DateTimeRangeTest.php | 0 .../Kernel/ValueObject/DateTimeTest.php | 0 .../Kernel/ValueObject/DateTimeTestBase.php | 2 +- .../Kernel/ValueObject/ImageTest.php | 2 +- .../Kernel/Webtools/SocialShareTest.php | 0 .../patterns/date_block_pattern_rendering.yml | 0 .../patterns/file_pattern_rendering.yml | 0 .../organisation_teaser_rendering.yml | 0 .../patterns/page_header_rendering.yml | 0 tests/{ => src}/Kernel/fixtures/rendering.yml | 0 .../Kernel/fixtures/table_rendering.yml | 0 .../PatternAssertions/BasePatternAssert.php | 2 + .../PatternAssertions/FeaturedItemAssert.php | 0 .../PatternAssertions/FieldListAssert.php | 0 .../PatternAssertions/FileAssert.php | 0 .../PatternAssertions/FileTeaserAssert.php | 0 .../FileTranslationAssert.php | 0 .../PatternAssertions/IconsTextAssert.php | 0 .../InPageNavigationAssert.php | 0 .../PatternAssertions/LinkBlockAssert.php | 0 .../PatternAssertions/ListItemAssert.php | 0 .../PatternAssertInterface.php | 0 .../PatternAssertions/PatternAssertState.php | 0 .../PatternAssertStateInterface.php | 0 .../PatternPageHeaderAssert.php | 0 .../SocialMediaLinksAssert.php | 0 .../TextFeaturedMediaAssert.php | 0 tests/{ => src}/Traits/RenderTrait.php | 0 tests/{ => src}/Traits/RequestTrait.php | 0 tests/{ => src}/Unit/AbstractUnitTestBase.php | 0 .../Unit/ValueObject/DateValueObjectTest.php | 0 .../Unit/ValueObject/FileValueObjectTest.php | 0 .../GalleryItemValueObjectTest.php | 0 .../Unit/ValueObject/ImageValueObjectTest.php | 22 ---------- .../value_object/date_value_object.yml | 0 105 files changed, 49 insertions(+), 112 deletions(-) rename tests/{ => src}/Behat/CleanupContext.php (100%) rename tests/{ => src}/Behat/DrupalContext.php (100%) rename tests/{ => src}/Behat/EventContext.php (100%) rename tests/{ => src}/Behat/MinkContext.php (100%) rename tests/{ => src}/Behat/OeThemeTestContext.php (100%) rename tests/{ => src}/Behat/PreserveAnonymousPermissionsContext.php (100%) rename tests/{ => src}/Behat/Traits/UtilityTrait.php (100%) rename tests/{ => src}/EnsurePHPUnitBatchingTestListener.php (100%) rename tests/{ => src}/Functional/BreadcrumbTest.php (98%) rename tests/{ => src}/Functional/ConfigurationTest.php (96%) rename tests/{ => src}/Functional/ContentCallForProposalsRenderTest.php (99%) rename tests/{ => src}/Functional/ContentCallForTendersRenderTest.php (99%) rename tests/{ => src}/Functional/ContentConsultationRenderTest.php (99%) rename tests/{ => src}/Functional/ContentEventRenderTest.php (99%) rename tests/{ => src}/Functional/ContentNewsRenderTest.php (99%) rename tests/{ => src}/Functional/ContentOrganisationRenderTest.php (99%) rename tests/{ => src}/Functional/ContentPersonRenderTest.php (99%) rename tests/{ => src}/Functional/ContentProjectRenderTest.php (99%) rename tests/{ => src}/Functional/ContentPublicationRenderTest.php (99%) rename tests/{ => src}/Functional/ContentRenderTestBase.php (100%) rename tests/{ => src}/Functional/CorporateFooterRenderTest.php (99%) rename tests/{ => src}/Functional/ParagraphsTest.php (100%) rename tests/{ => src}/Functional/fixtures/ec_footer.yml (100%) rename tests/{ => src}/Functional/fixtures/eu_footer.yml (100%) rename tests/{ => src}/FunctionalJavascript/JavascriptBehavioursTest.php (98%) rename tests/{ => src}/Kernel/AbstractKernelTestBase.php (80%) rename tests/{ => src}/Kernel/BlockTest.php (95%) rename tests/{ => src}/Kernel/BreadcrumbTest.php (97%) rename tests/{ => src}/Kernel/CallForProposalsRenderTest.php (100%) rename tests/{ => src}/Kernel/CallForTendersRenderTest.php (100%) rename tests/{ => src}/Kernel/ConsultationRenderTest.php (100%) rename tests/{ => src}/Kernel/ContactFormRenderTest.php (97%) rename tests/{ => src}/Kernel/ContactRenderTest.php (100%) rename tests/{ => src}/Kernel/ContentLanguageSwitcherTest.php (98%) rename tests/{ => src}/Kernel/ContentRenderTestBase.php (100%) rename tests/{ => src}/Kernel/EventRenderTest.php (100%) rename tests/{ => src}/Kernel/LanguageSwitcherTest.php (100%) rename tests/{ => src}/Kernel/LegacyContentRenderTest.php (100%) rename tests/{ => src}/Kernel/MainMenuTest.php (100%) rename tests/{ => src}/Kernel/MediaRenderTest.php (100%) rename tests/{ => src}/Kernel/MenuLocalTasksTest.php (100%) rename tests/{ => src}/Kernel/MultilingualAbstractKernelTestBase.php (100%) rename tests/{ => src}/Kernel/NewsRenderTest.php (100%) rename tests/{ => src}/Kernel/OrganisationRenderTest.php (100%) rename tests/{ => src}/Kernel/PagerTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/ContactParagraphTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/ContentRowTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/MediaParagraphsTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/ParagraphsTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/ParagraphsTestBase.php (100%) rename tests/{ => src}/Kernel/Paragraphs/SocialMediaFollowTest.php (100%) rename tests/{ => src}/Kernel/Paragraphs/TimelineParagraphTest.php (100%) rename tests/{ => src}/Kernel/Patterns/DateBlockPatternRenderingTest.php (100%) rename tests/{ => src}/Kernel/Patterns/FilePatternRenderingTest.php (100%) rename tests/{ => src}/Kernel/Patterns/LinkPatternRenderingTest.php (100%) rename tests/{ => src}/Kernel/Patterns/OrganisationTeaserPatternRenderingTest.php (100%) rename tests/{ => src}/Kernel/Patterns/PageHeaderRenderingTest.php (100%) rename tests/{ => src}/Kernel/PersonRenderTest.php (100%) rename tests/{ => src}/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php (100%) rename tests/{ => src}/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php (100%) rename tests/{ => src}/Kernel/ProjectRenderTest.php (100%) rename tests/{ => src}/Kernel/PublicationRenderTest.php (100%) rename tests/{ => src}/Kernel/RenderingTest.php (100%) rename tests/{ => src}/Kernel/SearchFormBlockTest.php (100%) rename tests/{ => src}/Kernel/StatusMessagesTest.php (100%) rename tests/{ => src}/Kernel/TablesTest.php (100%) rename tests/{ => src}/Kernel/TimelineTest.php (97%) rename tests/{ => src}/Kernel/ValueObject/DateTimeRangeTest.php (100%) rename tests/{ => src}/Kernel/ValueObject/DateTimeTest.php (100%) rename tests/{ => src}/Kernel/ValueObject/DateTimeTestBase.php (96%) rename tests/{ => src}/Kernel/ValueObject/ImageTest.php (95%) rename tests/{ => src}/Kernel/Webtools/SocialShareTest.php (100%) rename tests/{ => src}/Kernel/fixtures/patterns/date_block_pattern_rendering.yml (100%) rename tests/{ => src}/Kernel/fixtures/patterns/file_pattern_rendering.yml (100%) rename tests/{ => src}/Kernel/fixtures/patterns/organisation_teaser_rendering.yml (100%) rename tests/{ => src}/Kernel/fixtures/patterns/page_header_rendering.yml (100%) rename tests/{ => src}/Kernel/fixtures/rendering.yml (100%) rename tests/{ => src}/Kernel/fixtures/table_rendering.yml (100%) rename tests/{ => src}/PatternAssertions/BasePatternAssert.php (98%) rename tests/{ => src}/PatternAssertions/FeaturedItemAssert.php (100%) rename tests/{ => src}/PatternAssertions/FieldListAssert.php (100%) rename tests/{ => src}/PatternAssertions/FileAssert.php (100%) rename tests/{ => src}/PatternAssertions/FileTeaserAssert.php (100%) rename tests/{ => src}/PatternAssertions/FileTranslationAssert.php (100%) rename tests/{ => src}/PatternAssertions/IconsTextAssert.php (100%) rename tests/{ => src}/PatternAssertions/InPageNavigationAssert.php (100%) rename tests/{ => src}/PatternAssertions/LinkBlockAssert.php (100%) rename tests/{ => src}/PatternAssertions/ListItemAssert.php (100%) rename tests/{ => src}/PatternAssertions/PatternAssertInterface.php (100%) rename tests/{ => src}/PatternAssertions/PatternAssertState.php (100%) rename tests/{ => src}/PatternAssertions/PatternAssertStateInterface.php (100%) rename tests/{ => src}/PatternAssertions/PatternPageHeaderAssert.php (100%) rename tests/{ => src}/PatternAssertions/SocialMediaLinksAssert.php (100%) rename tests/{ => src}/PatternAssertions/TextFeaturedMediaAssert.php (100%) rename tests/{ => src}/Traits/RenderTrait.php (100%) rename tests/{ => src}/Traits/RequestTrait.php (100%) rename tests/{ => src}/Unit/AbstractUnitTestBase.php (100%) rename tests/{ => src}/Unit/ValueObject/DateValueObjectTest.php (100%) rename tests/{ => src}/Unit/ValueObject/FileValueObjectTest.php (100%) rename tests/{ => src}/Unit/ValueObject/GalleryItemValueObjectTest.php (100%) rename tests/{ => src}/Unit/ValueObject/ImageValueObjectTest.php (91%) rename tests/{ => src}/Unit/fixtures/value_object/date_value_object.yml (100%) diff --git a/composer.json b/composer.json index 34420c303..2448c06e4 100644 --- a/composer.json +++ b/composer.json @@ -7,34 +7,34 @@ "prefer-stable": true, "require": { "php": ">=7.3", - "drupal/core": "^8.9.16 || ^9.1", - "drupal/smart_trim": "^1.3", + "drupal/core": "^8.9.14 || ^9.1", + "drupal/smart_trim": "^1.2", "drupal/twig_field_value": "^2.0", - "drupal/ui_patterns": "^1.2", + "drupal/ui_patterns": "^1.0", "openeuropa/ecl-twig-loader": "dev-OEL-337", - "openeuropa/oe_time_caching": "dev-master", + "openeuropa/oe_time_caching": "~1.0", "ralouphie/mimey": "^2.1" }, "require-dev": { - "composer/installers": "~1.11", - "consolidation/annotated-command": "^2.12", + "composer/installers": "~1.5", + "consolidation/annotated-command": "^2.8.2", "consolidation/robo": "~1.4", - "cweagans/composer-patches": "~1.7.1", + "cweagans/composer-patches": "~1.6.7", "drupal/core-composer-scaffold": "^8.9 || ^9.1", "drupal/address": "~1.9", - "drupal/composite_reference": "~1.0-alpha2", - "drupal/config_devel": "~1.8", + "drupal/composite_reference": "~1.0-alpha1", + "drupal/config_devel": "~1.2", "drupal/datetime_testing": "1.x-dev", "drupal/description_list_field": "1.0.x-dev", "drupal/drupal-driver": "^2.1.1", - "drupal/drupal-extension": "~4.1", + "drupal/drupal-extension": "~4.0", "drupal/emr": "~1.0-beta9", - "drupal/entity_reference_revisions": "~1.9", - "drupal/entity_browser": "^2.6", - "drupal/extra_field": "^1.3", - "drupal/field_group": "^3.1", + "drupal/entity_reference_revisions": "~1.3", + "drupal/entity_browser": "^2.5", + "drupal/extra_field": "^1.1", + "drupal/field_group": "~3.0", "drupal/inline_entity_form": "~1.0-rc9", - "drupal/json_field": "^1.0.0-rc4", + "drupal/json_field": "^1.0.0-rc2", "drupal/renderviz": "^1.0@alpha", "drupal/styleguide": "~1.0@beta", "drupal/typed_link": "~1.1", @@ -47,7 +47,7 @@ "openeuropa/code-review": "~1.6", "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", "openeuropa/oe_content": "dev-EWPP-911", - "openeuropa/oe_corporate_blocks": "~4.1", + "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", @@ -56,17 +56,15 @@ "openeuropa/oe_webtools": "~1.12", "openeuropa/oe_contact_forms": "dev-OEL-164", "openeuropa/rdf_skos": "~1.0", - "openeuropa/task-runner-drupal-project-symlink": "^1.0.0-beta3", - "phpspec/prophecy-phpunit": "^1 || ^2", - "symfony/dom-crawler": "~4.4" + "openeuropa/task-runner-drupal-project-symlink": "^1.0", + "phpspec/prophecy-phpunit": "^1 || ^2" }, "_readme": [ "We explicitly require consolidation/robo to allow lower 'composer update --prefer-lowest' to complete successfully.", "We explicitly require consolidation/annotated-command to allow lower 'composer update --prefer-lowest' to complete successfully.", "We explicity require drupal/core to allow lower 'composer update --prefer-lowest' to complete successfully.", "openeuropa/oe_search is used from a branch because of major upgrading is pending. Change again when it released.", - "openeuropa/ecl-twig-loader is used from a branch because it must be upgrade to be D9 compatible. Change again when it released.", - "openeuropa/oe_multilingual is used from a branch because it has an issue with D9. Change again when it released." + "openeuropa/ecl-twig-loader is used from a branch because it must be upgrade to be D9 compatible. Change again when it released." ], "conflict": { "openeuropa/oe_corporate_blocks": "<3.0.0", @@ -83,7 +81,7 @@ }, "autoload-dev": { "psr-4": { - "Drupal\\Tests\\oe_theme\\": "./tests/", + "Drupal\\Tests\\oe_theme\\": "./tests/src/", "Drupal\\Tests\\oe_content\\": "./build/modules/contrib/oe_content/tests/src/", "Drupal\\Tests\\oe_media\\": "./build/modules/contrib/oe_media/tests/src/" } diff --git a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php index 0e8266255..5f7fb9e55 100644 --- a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php +++ b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php @@ -35,7 +35,7 @@ public function setUp(): void { // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by diff --git a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php index e37418540..d96b3d9ab 100644 --- a/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php +++ b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationLibraryTest.php @@ -38,7 +38,7 @@ public function setUp(): void { // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by diff --git a/tests/Behat/CleanupContext.php b/tests/src/Behat/CleanupContext.php similarity index 100% rename from tests/Behat/CleanupContext.php rename to tests/src/Behat/CleanupContext.php diff --git a/tests/Behat/DrupalContext.php b/tests/src/Behat/DrupalContext.php similarity index 100% rename from tests/Behat/DrupalContext.php rename to tests/src/Behat/DrupalContext.php diff --git a/tests/Behat/EventContext.php b/tests/src/Behat/EventContext.php similarity index 100% rename from tests/Behat/EventContext.php rename to tests/src/Behat/EventContext.php diff --git a/tests/Behat/MinkContext.php b/tests/src/Behat/MinkContext.php similarity index 100% rename from tests/Behat/MinkContext.php rename to tests/src/Behat/MinkContext.php diff --git a/tests/Behat/OeThemeTestContext.php b/tests/src/Behat/OeThemeTestContext.php similarity index 100% rename from tests/Behat/OeThemeTestContext.php rename to tests/src/Behat/OeThemeTestContext.php diff --git a/tests/Behat/PreserveAnonymousPermissionsContext.php b/tests/src/Behat/PreserveAnonymousPermissionsContext.php similarity index 100% rename from tests/Behat/PreserveAnonymousPermissionsContext.php rename to tests/src/Behat/PreserveAnonymousPermissionsContext.php diff --git a/tests/Behat/Traits/UtilityTrait.php b/tests/src/Behat/Traits/UtilityTrait.php similarity index 100% rename from tests/Behat/Traits/UtilityTrait.php rename to tests/src/Behat/Traits/UtilityTrait.php diff --git a/tests/EnsurePHPUnitBatchingTestListener.php b/tests/src/EnsurePHPUnitBatchingTestListener.php similarity index 100% rename from tests/EnsurePHPUnitBatchingTestListener.php rename to tests/src/EnsurePHPUnitBatchingTestListener.php diff --git a/tests/Functional/BreadcrumbTest.php b/tests/src/Functional/BreadcrumbTest.php similarity index 98% rename from tests/Functional/BreadcrumbTest.php rename to tests/src/Functional/BreadcrumbTest.php index 559e5bc08..0a5ab9f2a 100644 --- a/tests/Functional/BreadcrumbTest.php +++ b/tests/src/Functional/BreadcrumbTest.php @@ -23,12 +23,6 @@ class BreadcrumbTest extends ContentRenderTestBase { 'block', ]; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * Tests that the breadcrumbs are cached correctly. */ diff --git a/tests/Functional/ConfigurationTest.php b/tests/src/Functional/ConfigurationTest.php similarity index 96% rename from tests/Functional/ConfigurationTest.php rename to tests/src/Functional/ConfigurationTest.php index 21cf74bf0..6423e0bde 100755 --- a/tests/Functional/ConfigurationTest.php +++ b/tests/src/Functional/ConfigurationTest.php @@ -45,7 +45,7 @@ protected function setUp(): void { */ public function testDefaultLibraryLoading(): void { foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); + $this->config('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); $this->drupalGet(''); @@ -76,7 +76,7 @@ public function testDefaultLibraryLoading(): void { */ public function testChangeComponentLibrary(): void { foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); + $this->config('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); $page = $this->getSession()->getPage(); @@ -164,7 +164,7 @@ public function testChangeEclBranding(): void { $page = $this->getSession()->getPage(); $assert_session = $this->assertSession(); foreach (['oe_theme', 'oe_theme_subtheme_test'] as $active_theme) { - $this->container->get('config.factory')->getEditable('system.theme')->set('default', $active_theme)->save(); + $this->config('system.theme')->set('default', $active_theme)->save(); $this->container->set('theme.registry', NULL); // Create a user that does have permission to administer theme settings. diff --git a/tests/Functional/ContentCallForProposalsRenderTest.php b/tests/src/Functional/ContentCallForProposalsRenderTest.php similarity index 99% rename from tests/Functional/ContentCallForProposalsRenderTest.php rename to tests/src/Functional/ContentCallForProposalsRenderTest.php index 00a3a26a4..1a12474f9 100644 --- a/tests/Functional/ContentCallForProposalsRenderTest.php +++ b/tests/src/Functional/ContentCallForProposalsRenderTest.php @@ -35,12 +35,6 @@ class ContentCallForProposalsRenderTest extends ContentRenderTestBase { 'oe_theme_content_call_proposals', ]; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentCallForTendersRenderTest.php b/tests/src/Functional/ContentCallForTendersRenderTest.php similarity index 99% rename from tests/Functional/ContentCallForTendersRenderTest.php rename to tests/src/Functional/ContentCallForTendersRenderTest.php index b0b52aef9..70ea92aca 100644 --- a/tests/Functional/ContentCallForTendersRenderTest.php +++ b/tests/src/Functional/ContentCallForTendersRenderTest.php @@ -34,11 +34,6 @@ class ContentCallForTendersRenderTest extends ContentRenderTestBase { 'datetime_testing', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * Tests that the Call for tenders page renders correctly. */ diff --git a/tests/Functional/ContentConsultationRenderTest.php b/tests/src/Functional/ContentConsultationRenderTest.php similarity index 99% rename from tests/Functional/ContentConsultationRenderTest.php rename to tests/src/Functional/ContentConsultationRenderTest.php index 3b7fae00f..185e25452 100644 --- a/tests/Functional/ContentConsultationRenderTest.php +++ b/tests/src/Functional/ContentConsultationRenderTest.php @@ -39,11 +39,6 @@ class ContentConsultationRenderTest extends ContentRenderTestBase { 'oe_theme_content_consultation', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentEventRenderTest.php b/tests/src/Functional/ContentEventRenderTest.php similarity index 99% rename from tests/Functional/ContentEventRenderTest.php rename to tests/src/Functional/ContentEventRenderTest.php index 252088399..04da50d81 100644 --- a/tests/Functional/ContentEventRenderTest.php +++ b/tests/src/Functional/ContentEventRenderTest.php @@ -40,11 +40,6 @@ class ContentEventRenderTest extends ContentRenderTestBase { 'path', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php similarity index 99% rename from tests/Functional/ContentNewsRenderTest.php rename to tests/src/Functional/ContentNewsRenderTest.php index 92daa758a..0e7686694 100644 --- a/tests/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -30,11 +30,6 @@ class ContentNewsRenderTest extends ContentRenderTestBase { 'block', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentOrganisationRenderTest.php b/tests/src/Functional/ContentOrganisationRenderTest.php similarity index 99% rename from tests/Functional/ContentOrganisationRenderTest.php rename to tests/src/Functional/ContentOrganisationRenderTest.php index 08d35539c..e7b873d54 100644 --- a/tests/Functional/ContentOrganisationRenderTest.php +++ b/tests/src/Functional/ContentOrganisationRenderTest.php @@ -37,11 +37,6 @@ class ContentOrganisationRenderTest extends ContentRenderTestBase { 'media_avportal_mock', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentPersonRenderTest.php b/tests/src/Functional/ContentPersonRenderTest.php similarity index 99% rename from tests/Functional/ContentPersonRenderTest.php rename to tests/src/Functional/ContentPersonRenderTest.php index b7562e088..28d38c0da 100644 --- a/tests/Functional/ContentPersonRenderTest.php +++ b/tests/src/Functional/ContentPersonRenderTest.php @@ -40,11 +40,6 @@ class ContentPersonRenderTest extends ContentRenderTestBase { 'oe_theme_content_person', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentProjectRenderTest.php b/tests/src/Functional/ContentProjectRenderTest.php similarity index 99% rename from tests/Functional/ContentProjectRenderTest.php rename to tests/src/Functional/ContentProjectRenderTest.php index 172181fb3..7a3555837 100644 --- a/tests/Functional/ContentProjectRenderTest.php +++ b/tests/src/Functional/ContentProjectRenderTest.php @@ -34,11 +34,6 @@ class ContentProjectRenderTest extends ContentRenderTestBase { 'options', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentPublicationRenderTest.php b/tests/src/Functional/ContentPublicationRenderTest.php similarity index 99% rename from tests/Functional/ContentPublicationRenderTest.php rename to tests/src/Functional/ContentPublicationRenderTest.php index 1148392e4..d1cb195cd 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/src/Functional/ContentPublicationRenderTest.php @@ -32,11 +32,6 @@ class ContentPublicationRenderTest extends ContentRenderTestBase { 'oe_theme_content_organisation_reference', ]; - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - /** * {@inheritdoc} */ diff --git a/tests/Functional/ContentRenderTestBase.php b/tests/src/Functional/ContentRenderTestBase.php similarity index 100% rename from tests/Functional/ContentRenderTestBase.php rename to tests/src/Functional/ContentRenderTestBase.php diff --git a/tests/Functional/CorporateFooterRenderTest.php b/tests/src/Functional/CorporateFooterRenderTest.php similarity index 99% rename from tests/Functional/CorporateFooterRenderTest.php rename to tests/src/Functional/CorporateFooterRenderTest.php index 145d2cc28..3dcb565e7 100644 --- a/tests/Functional/CorporateFooterRenderTest.php +++ b/tests/src/Functional/CorporateFooterRenderTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Rebuild the ui_pattern definitions to collect the ones provided by @@ -823,7 +823,7 @@ protected function assertSocialLink(NodeElement $label, NodeElement $link, array $this->assertEquals($expected['label'], $label->getText()); $this->assertEquals($expected['href'], $link->getAttribute('href')); $icon = $link->find('css', 'svg.ecl-icon.ecl-icon--xs.ecl-link__icon use'); - $this->assertContains('icons-social-media.svg#' . $expected['icon_name'], $icon->getAttribute('xlink:href')); + $this->assertStringContainsString('icons-social-media.svg#' . $expected['icon_name'], $icon->getAttribute('xlink:href')); $this->assertEquals('ecl-link ecl-link--standalone ecl-link--icon ecl-link--icon-before ecl-footer-standardised__link', $link->getAttribute('class')); } diff --git a/tests/Functional/ParagraphsTest.php b/tests/src/Functional/ParagraphsTest.php similarity index 100% rename from tests/Functional/ParagraphsTest.php rename to tests/src/Functional/ParagraphsTest.php diff --git a/tests/Functional/fixtures/ec_footer.yml b/tests/src/Functional/fixtures/ec_footer.yml similarity index 100% rename from tests/Functional/fixtures/ec_footer.yml rename to tests/src/Functional/fixtures/ec_footer.yml diff --git a/tests/Functional/fixtures/eu_footer.yml b/tests/src/Functional/fixtures/eu_footer.yml similarity index 100% rename from tests/Functional/fixtures/eu_footer.yml rename to tests/src/Functional/fixtures/eu_footer.yml diff --git a/tests/FunctionalJavascript/JavascriptBehavioursTest.php b/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php similarity index 98% rename from tests/FunctionalJavascript/JavascriptBehavioursTest.php rename to tests/src/FunctionalJavascript/JavascriptBehavioursTest.php index 669285207..9a3f1c779 100644 --- a/tests/FunctionalJavascript/JavascriptBehavioursTest.php +++ b/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php @@ -39,7 +39,7 @@ protected function setUp(): void { // Enable and set OpenEuropa Theme as default. $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } diff --git a/tests/Kernel/AbstractKernelTestBase.php b/tests/src/Kernel/AbstractKernelTestBase.php similarity index 80% rename from tests/Kernel/AbstractKernelTestBase.php rename to tests/src/Kernel/AbstractKernelTestBase.php index e5edd1f8c..8b7ef87e0 100644 --- a/tests/Kernel/AbstractKernelTestBase.php +++ b/tests/src/Kernel/AbstractKernelTestBase.php @@ -7,6 +7,7 @@ use Drupal\Core\Plugin\ContextAwarePluginInterface; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\oe_theme\Traits\RenderTrait; +use Drupal\Core\Site\Settings; use Symfony\Component\Yaml\Yaml; /** @@ -49,9 +50,19 @@ protected function setUp(): void { ]); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); + // @todo Drupal 9 ignores settings in settings.testing.php in kernel tests. + // See https://www.drupal.org/project/drupal/issues/3190974. Need to + // skip node_modules directory during template scanning because wrong + // template files are found (for example, + // node_modules/@ecl/twig-component-description-list/description-list.html.twig + // instead of templates/field/description-list.html.twig + $settings = Settings::getAll(); + $settings['file_scan_ignore_directories'] = ['node_modules']; + new Settings($settings); + // 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 diff --git a/tests/Kernel/BlockTest.php b/tests/src/Kernel/BlockTest.php similarity index 95% rename from tests/Kernel/BlockTest.php rename to tests/src/Kernel/BlockTest.php index d833e7609..c7f5709ff 100644 --- a/tests/Kernel/BlockTest.php +++ b/tests/src/Kernel/BlockTest.php @@ -52,7 +52,7 @@ protected function setUp(): void { ]); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } diff --git a/tests/Kernel/BreadcrumbTest.php b/tests/src/Kernel/BreadcrumbTest.php similarity index 97% rename from tests/Kernel/BreadcrumbTest.php rename to tests/src/Kernel/BreadcrumbTest.php index 5966afa49..461366544 100644 --- a/tests/Kernel/BreadcrumbTest.php +++ b/tests/src/Kernel/BreadcrumbTest.php @@ -47,7 +47,7 @@ protected function setUp(): void { $this->installConfig(['system', 'image', 'responsive_image']); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Call the install hook of the User module which creates the Anonymous user diff --git a/tests/Kernel/CallForProposalsRenderTest.php b/tests/src/Kernel/CallForProposalsRenderTest.php similarity index 100% rename from tests/Kernel/CallForProposalsRenderTest.php rename to tests/src/Kernel/CallForProposalsRenderTest.php diff --git a/tests/Kernel/CallForTendersRenderTest.php b/tests/src/Kernel/CallForTendersRenderTest.php similarity index 100% rename from tests/Kernel/CallForTendersRenderTest.php rename to tests/src/Kernel/CallForTendersRenderTest.php diff --git a/tests/Kernel/ConsultationRenderTest.php b/tests/src/Kernel/ConsultationRenderTest.php similarity index 100% rename from tests/Kernel/ConsultationRenderTest.php rename to tests/src/Kernel/ConsultationRenderTest.php diff --git a/tests/Kernel/ContactFormRenderTest.php b/tests/src/Kernel/ContactFormRenderTest.php similarity index 97% rename from tests/Kernel/ContactFormRenderTest.php rename to tests/src/Kernel/ContactFormRenderTest.php index 80730eb95..74f58c831 100644 --- a/tests/Kernel/ContactFormRenderTest.php +++ b/tests/src/Kernel/ContactFormRenderTest.php @@ -36,7 +36,7 @@ protected function setUp(): void { $this->installConfig(['system', 'image', 'responsive_image', 'contact']); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); } diff --git a/tests/Kernel/ContactRenderTest.php b/tests/src/Kernel/ContactRenderTest.php similarity index 100% rename from tests/Kernel/ContactRenderTest.php rename to tests/src/Kernel/ContactRenderTest.php diff --git a/tests/Kernel/ContentLanguageSwitcherTest.php b/tests/src/Kernel/ContentLanguageSwitcherTest.php similarity index 98% rename from tests/Kernel/ContentLanguageSwitcherTest.php rename to tests/src/Kernel/ContentLanguageSwitcherTest.php index 6cea36cee..de8f812bb 100644 --- a/tests/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -112,7 +112,7 @@ public function testLanguageSwitcherRendering(): void { */ protected function assertUnavailableLanguage(Crawler $crawler, string $expected): void { $actual = $crawler->filter('div.ecl-lang-select-page div.ecl-container div.ecl-message--warning')->text(); - $this->assertContains($expected, trim($actual)); + $this->assertStringContainsString($expected, trim($actual)); } /** diff --git a/tests/Kernel/ContentRenderTestBase.php b/tests/src/Kernel/ContentRenderTestBase.php similarity index 100% rename from tests/Kernel/ContentRenderTestBase.php rename to tests/src/Kernel/ContentRenderTestBase.php diff --git a/tests/Kernel/EventRenderTest.php b/tests/src/Kernel/EventRenderTest.php similarity index 100% rename from tests/Kernel/EventRenderTest.php rename to tests/src/Kernel/EventRenderTest.php diff --git a/tests/Kernel/LanguageSwitcherTest.php b/tests/src/Kernel/LanguageSwitcherTest.php similarity index 100% rename from tests/Kernel/LanguageSwitcherTest.php rename to tests/src/Kernel/LanguageSwitcherTest.php diff --git a/tests/Kernel/LegacyContentRenderTest.php b/tests/src/Kernel/LegacyContentRenderTest.php similarity index 100% rename from tests/Kernel/LegacyContentRenderTest.php rename to tests/src/Kernel/LegacyContentRenderTest.php diff --git a/tests/Kernel/MainMenuTest.php b/tests/src/Kernel/MainMenuTest.php similarity index 100% rename from tests/Kernel/MainMenuTest.php rename to tests/src/Kernel/MainMenuTest.php diff --git a/tests/Kernel/MediaRenderTest.php b/tests/src/Kernel/MediaRenderTest.php similarity index 100% rename from tests/Kernel/MediaRenderTest.php rename to tests/src/Kernel/MediaRenderTest.php diff --git a/tests/Kernel/MenuLocalTasksTest.php b/tests/src/Kernel/MenuLocalTasksTest.php similarity index 100% rename from tests/Kernel/MenuLocalTasksTest.php rename to tests/src/Kernel/MenuLocalTasksTest.php diff --git a/tests/Kernel/MultilingualAbstractKernelTestBase.php b/tests/src/Kernel/MultilingualAbstractKernelTestBase.php similarity index 100% rename from tests/Kernel/MultilingualAbstractKernelTestBase.php rename to tests/src/Kernel/MultilingualAbstractKernelTestBase.php diff --git a/tests/Kernel/NewsRenderTest.php b/tests/src/Kernel/NewsRenderTest.php similarity index 100% rename from tests/Kernel/NewsRenderTest.php rename to tests/src/Kernel/NewsRenderTest.php diff --git a/tests/Kernel/OrganisationRenderTest.php b/tests/src/Kernel/OrganisationRenderTest.php similarity index 100% rename from tests/Kernel/OrganisationRenderTest.php rename to tests/src/Kernel/OrganisationRenderTest.php diff --git a/tests/Kernel/PagerTest.php b/tests/src/Kernel/PagerTest.php similarity index 100% rename from tests/Kernel/PagerTest.php rename to tests/src/Kernel/PagerTest.php diff --git a/tests/Kernel/Paragraphs/ContactParagraphTest.php b/tests/src/Kernel/Paragraphs/ContactParagraphTest.php similarity index 100% rename from tests/Kernel/Paragraphs/ContactParagraphTest.php rename to tests/src/Kernel/Paragraphs/ContactParagraphTest.php diff --git a/tests/Kernel/Paragraphs/ContentRowTest.php b/tests/src/Kernel/Paragraphs/ContentRowTest.php similarity index 100% rename from tests/Kernel/Paragraphs/ContentRowTest.php rename to tests/src/Kernel/Paragraphs/ContentRowTest.php diff --git a/tests/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php similarity index 100% rename from tests/Kernel/Paragraphs/MediaParagraphsTest.php rename to tests/src/Kernel/Paragraphs/MediaParagraphsTest.php diff --git a/tests/Kernel/Paragraphs/ParagraphsTest.php b/tests/src/Kernel/Paragraphs/ParagraphsTest.php similarity index 100% rename from tests/Kernel/Paragraphs/ParagraphsTest.php rename to tests/src/Kernel/Paragraphs/ParagraphsTest.php diff --git a/tests/Kernel/Paragraphs/ParagraphsTestBase.php b/tests/src/Kernel/Paragraphs/ParagraphsTestBase.php similarity index 100% rename from tests/Kernel/Paragraphs/ParagraphsTestBase.php rename to tests/src/Kernel/Paragraphs/ParagraphsTestBase.php diff --git a/tests/Kernel/Paragraphs/SocialMediaFollowTest.php b/tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php similarity index 100% rename from tests/Kernel/Paragraphs/SocialMediaFollowTest.php rename to tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php diff --git a/tests/Kernel/Paragraphs/TimelineParagraphTest.php b/tests/src/Kernel/Paragraphs/TimelineParagraphTest.php similarity index 100% rename from tests/Kernel/Paragraphs/TimelineParagraphTest.php rename to tests/src/Kernel/Paragraphs/TimelineParagraphTest.php diff --git a/tests/Kernel/Patterns/DateBlockPatternRenderingTest.php b/tests/src/Kernel/Patterns/DateBlockPatternRenderingTest.php similarity index 100% rename from tests/Kernel/Patterns/DateBlockPatternRenderingTest.php rename to tests/src/Kernel/Patterns/DateBlockPatternRenderingTest.php diff --git a/tests/Kernel/Patterns/FilePatternRenderingTest.php b/tests/src/Kernel/Patterns/FilePatternRenderingTest.php similarity index 100% rename from tests/Kernel/Patterns/FilePatternRenderingTest.php rename to tests/src/Kernel/Patterns/FilePatternRenderingTest.php diff --git a/tests/Kernel/Patterns/LinkPatternRenderingTest.php b/tests/src/Kernel/Patterns/LinkPatternRenderingTest.php similarity index 100% rename from tests/Kernel/Patterns/LinkPatternRenderingTest.php rename to tests/src/Kernel/Patterns/LinkPatternRenderingTest.php diff --git a/tests/Kernel/Patterns/OrganisationTeaserPatternRenderingTest.php b/tests/src/Kernel/Patterns/OrganisationTeaserPatternRenderingTest.php similarity index 100% rename from tests/Kernel/Patterns/OrganisationTeaserPatternRenderingTest.php rename to tests/src/Kernel/Patterns/OrganisationTeaserPatternRenderingTest.php diff --git a/tests/Kernel/Patterns/PageHeaderRenderingTest.php b/tests/src/Kernel/Patterns/PageHeaderRenderingTest.php similarity index 100% rename from tests/Kernel/Patterns/PageHeaderRenderingTest.php rename to tests/src/Kernel/Patterns/PageHeaderRenderingTest.php diff --git a/tests/Kernel/PersonRenderTest.php b/tests/src/Kernel/PersonRenderTest.php similarity index 100% rename from tests/Kernel/PersonRenderTest.php rename to tests/src/Kernel/PersonRenderTest.php diff --git a/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php b/tests/src/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php similarity index 100% rename from tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php rename to tests/src/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php diff --git a/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php b/tests/src/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php similarity index 100% rename from tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php rename to tests/src/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php diff --git a/tests/Kernel/ProjectRenderTest.php b/tests/src/Kernel/ProjectRenderTest.php similarity index 100% rename from tests/Kernel/ProjectRenderTest.php rename to tests/src/Kernel/ProjectRenderTest.php diff --git a/tests/Kernel/PublicationRenderTest.php b/tests/src/Kernel/PublicationRenderTest.php similarity index 100% rename from tests/Kernel/PublicationRenderTest.php rename to tests/src/Kernel/PublicationRenderTest.php diff --git a/tests/Kernel/RenderingTest.php b/tests/src/Kernel/RenderingTest.php similarity index 100% rename from tests/Kernel/RenderingTest.php rename to tests/src/Kernel/RenderingTest.php diff --git a/tests/Kernel/SearchFormBlockTest.php b/tests/src/Kernel/SearchFormBlockTest.php similarity index 100% rename from tests/Kernel/SearchFormBlockTest.php rename to tests/src/Kernel/SearchFormBlockTest.php diff --git a/tests/Kernel/StatusMessagesTest.php b/tests/src/Kernel/StatusMessagesTest.php similarity index 100% rename from tests/Kernel/StatusMessagesTest.php rename to tests/src/Kernel/StatusMessagesTest.php diff --git a/tests/Kernel/TablesTest.php b/tests/src/Kernel/TablesTest.php similarity index 100% rename from tests/Kernel/TablesTest.php rename to tests/src/Kernel/TablesTest.php diff --git a/tests/Kernel/TimelineTest.php b/tests/src/Kernel/TimelineTest.php similarity index 97% rename from tests/Kernel/TimelineTest.php rename to tests/src/Kernel/TimelineTest.php index ca21e2d97..3b13a2048 100644 --- a/tests/Kernel/TimelineTest.php +++ b/tests/src/Kernel/TimelineTest.php @@ -84,7 +84,7 @@ protected function setUp(): void { $this->installEntitySchema('skos_concept_scheme'); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); // Create content type. diff --git a/tests/Kernel/ValueObject/DateTimeRangeTest.php b/tests/src/Kernel/ValueObject/DateTimeRangeTest.php similarity index 100% rename from tests/Kernel/ValueObject/DateTimeRangeTest.php rename to tests/src/Kernel/ValueObject/DateTimeRangeTest.php diff --git a/tests/Kernel/ValueObject/DateTimeTest.php b/tests/src/Kernel/ValueObject/DateTimeTest.php similarity index 100% rename from tests/Kernel/ValueObject/DateTimeTest.php rename to tests/src/Kernel/ValueObject/DateTimeTest.php diff --git a/tests/Kernel/ValueObject/DateTimeTestBase.php b/tests/src/Kernel/ValueObject/DateTimeTestBase.php similarity index 96% rename from tests/Kernel/ValueObject/DateTimeTestBase.php rename to tests/src/Kernel/ValueObject/DateTimeTestBase.php index 063f3e055..8db40d322 100644 --- a/tests/Kernel/ValueObject/DateTimeTestBase.php +++ b/tests/src/Kernel/ValueObject/DateTimeTestBase.php @@ -35,7 +35,7 @@ protected function setUp(): void { parent::setUp(); $this->container->get('theme_installer')->install(['oe_theme']); - \Drupal::configFactory()->getEditable('system.theme')->set('default', 'oe_theme')->save(); + $this->config('system.theme')->set('default', 'oe_theme')->save(); $this->container->set('theme.registry', NULL); $this->installConfig(['image', 'responsive_image']); } diff --git a/tests/Kernel/ValueObject/ImageTest.php b/tests/src/Kernel/ValueObject/ImageTest.php similarity index 95% rename from tests/Kernel/ValueObject/ImageTest.php rename to tests/src/Kernel/ValueObject/ImageTest.php index 717dc1837..d6286839a 100644 --- a/tests/Kernel/ValueObject/ImageTest.php +++ b/tests/src/Kernel/ValueObject/ImageTest.php @@ -55,7 +55,7 @@ protected function setUp(): void { ])->save(); // Copy file in public files to use it for styling. - \Drupal::service('file_system')->copy(__DIR__ . '/../../fixtures/example_1.jpeg', 'public://example_1.jpg'); + \Drupal::service('file_system')->copy(__DIR__ . '/../../../fixtures/example_1.jpeg', 'public://example_1.jpg'); } /** diff --git a/tests/Kernel/Webtools/SocialShareTest.php b/tests/src/Kernel/Webtools/SocialShareTest.php similarity index 100% rename from tests/Kernel/Webtools/SocialShareTest.php rename to tests/src/Kernel/Webtools/SocialShareTest.php diff --git a/tests/Kernel/fixtures/patterns/date_block_pattern_rendering.yml b/tests/src/Kernel/fixtures/patterns/date_block_pattern_rendering.yml similarity index 100% rename from tests/Kernel/fixtures/patterns/date_block_pattern_rendering.yml rename to tests/src/Kernel/fixtures/patterns/date_block_pattern_rendering.yml diff --git a/tests/Kernel/fixtures/patterns/file_pattern_rendering.yml b/tests/src/Kernel/fixtures/patterns/file_pattern_rendering.yml similarity index 100% rename from tests/Kernel/fixtures/patterns/file_pattern_rendering.yml rename to tests/src/Kernel/fixtures/patterns/file_pattern_rendering.yml diff --git a/tests/Kernel/fixtures/patterns/organisation_teaser_rendering.yml b/tests/src/Kernel/fixtures/patterns/organisation_teaser_rendering.yml similarity index 100% rename from tests/Kernel/fixtures/patterns/organisation_teaser_rendering.yml rename to tests/src/Kernel/fixtures/patterns/organisation_teaser_rendering.yml diff --git a/tests/Kernel/fixtures/patterns/page_header_rendering.yml b/tests/src/Kernel/fixtures/patterns/page_header_rendering.yml similarity index 100% rename from tests/Kernel/fixtures/patterns/page_header_rendering.yml rename to tests/src/Kernel/fixtures/patterns/page_header_rendering.yml diff --git a/tests/Kernel/fixtures/rendering.yml b/tests/src/Kernel/fixtures/rendering.yml similarity index 100% rename from tests/Kernel/fixtures/rendering.yml rename to tests/src/Kernel/fixtures/rendering.yml diff --git a/tests/Kernel/fixtures/table_rendering.yml b/tests/src/Kernel/fixtures/table_rendering.yml similarity index 100% rename from tests/Kernel/fixtures/table_rendering.yml rename to tests/src/Kernel/fixtures/table_rendering.yml diff --git a/tests/PatternAssertions/BasePatternAssert.php b/tests/src/PatternAssertions/BasePatternAssert.php similarity index 98% rename from tests/PatternAssertions/BasePatternAssert.php rename to tests/src/PatternAssertions/BasePatternAssert.php index 5143ba0b7..571a72b9a 100644 --- a/tests/PatternAssertions/BasePatternAssert.php +++ b/tests/src/PatternAssertions/BasePatternAssert.php @@ -14,6 +14,8 @@ */ abstract class BasePatternAssert extends Assert implements PatternAssertInterface { + // Adds support of new asserts like assertStringContainsString() for + // PHPUnit 6.5. use PhpUnitCompatibilityTrait; /** diff --git a/tests/PatternAssertions/FeaturedItemAssert.php b/tests/src/PatternAssertions/FeaturedItemAssert.php similarity index 100% rename from tests/PatternAssertions/FeaturedItemAssert.php rename to tests/src/PatternAssertions/FeaturedItemAssert.php diff --git a/tests/PatternAssertions/FieldListAssert.php b/tests/src/PatternAssertions/FieldListAssert.php similarity index 100% rename from tests/PatternAssertions/FieldListAssert.php rename to tests/src/PatternAssertions/FieldListAssert.php diff --git a/tests/PatternAssertions/FileAssert.php b/tests/src/PatternAssertions/FileAssert.php similarity index 100% rename from tests/PatternAssertions/FileAssert.php rename to tests/src/PatternAssertions/FileAssert.php diff --git a/tests/PatternAssertions/FileTeaserAssert.php b/tests/src/PatternAssertions/FileTeaserAssert.php similarity index 100% rename from tests/PatternAssertions/FileTeaserAssert.php rename to tests/src/PatternAssertions/FileTeaserAssert.php diff --git a/tests/PatternAssertions/FileTranslationAssert.php b/tests/src/PatternAssertions/FileTranslationAssert.php similarity index 100% rename from tests/PatternAssertions/FileTranslationAssert.php rename to tests/src/PatternAssertions/FileTranslationAssert.php diff --git a/tests/PatternAssertions/IconsTextAssert.php b/tests/src/PatternAssertions/IconsTextAssert.php similarity index 100% rename from tests/PatternAssertions/IconsTextAssert.php rename to tests/src/PatternAssertions/IconsTextAssert.php diff --git a/tests/PatternAssertions/InPageNavigationAssert.php b/tests/src/PatternAssertions/InPageNavigationAssert.php similarity index 100% rename from tests/PatternAssertions/InPageNavigationAssert.php rename to tests/src/PatternAssertions/InPageNavigationAssert.php diff --git a/tests/PatternAssertions/LinkBlockAssert.php b/tests/src/PatternAssertions/LinkBlockAssert.php similarity index 100% rename from tests/PatternAssertions/LinkBlockAssert.php rename to tests/src/PatternAssertions/LinkBlockAssert.php diff --git a/tests/PatternAssertions/ListItemAssert.php b/tests/src/PatternAssertions/ListItemAssert.php similarity index 100% rename from tests/PatternAssertions/ListItemAssert.php rename to tests/src/PatternAssertions/ListItemAssert.php diff --git a/tests/PatternAssertions/PatternAssertInterface.php b/tests/src/PatternAssertions/PatternAssertInterface.php similarity index 100% rename from tests/PatternAssertions/PatternAssertInterface.php rename to tests/src/PatternAssertions/PatternAssertInterface.php diff --git a/tests/PatternAssertions/PatternAssertState.php b/tests/src/PatternAssertions/PatternAssertState.php similarity index 100% rename from tests/PatternAssertions/PatternAssertState.php rename to tests/src/PatternAssertions/PatternAssertState.php diff --git a/tests/PatternAssertions/PatternAssertStateInterface.php b/tests/src/PatternAssertions/PatternAssertStateInterface.php similarity index 100% rename from tests/PatternAssertions/PatternAssertStateInterface.php rename to tests/src/PatternAssertions/PatternAssertStateInterface.php diff --git a/tests/PatternAssertions/PatternPageHeaderAssert.php b/tests/src/PatternAssertions/PatternPageHeaderAssert.php similarity index 100% rename from tests/PatternAssertions/PatternPageHeaderAssert.php rename to tests/src/PatternAssertions/PatternPageHeaderAssert.php diff --git a/tests/PatternAssertions/SocialMediaLinksAssert.php b/tests/src/PatternAssertions/SocialMediaLinksAssert.php similarity index 100% rename from tests/PatternAssertions/SocialMediaLinksAssert.php rename to tests/src/PatternAssertions/SocialMediaLinksAssert.php diff --git a/tests/PatternAssertions/TextFeaturedMediaAssert.php b/tests/src/PatternAssertions/TextFeaturedMediaAssert.php similarity index 100% rename from tests/PatternAssertions/TextFeaturedMediaAssert.php rename to tests/src/PatternAssertions/TextFeaturedMediaAssert.php diff --git a/tests/Traits/RenderTrait.php b/tests/src/Traits/RenderTrait.php similarity index 100% rename from tests/Traits/RenderTrait.php rename to tests/src/Traits/RenderTrait.php diff --git a/tests/Traits/RequestTrait.php b/tests/src/Traits/RequestTrait.php similarity index 100% rename from tests/Traits/RequestTrait.php rename to tests/src/Traits/RequestTrait.php diff --git a/tests/Unit/AbstractUnitTestBase.php b/tests/src/Unit/AbstractUnitTestBase.php similarity index 100% rename from tests/Unit/AbstractUnitTestBase.php rename to tests/src/Unit/AbstractUnitTestBase.php diff --git a/tests/Unit/ValueObject/DateValueObjectTest.php b/tests/src/Unit/ValueObject/DateValueObjectTest.php similarity index 100% rename from tests/Unit/ValueObject/DateValueObjectTest.php rename to tests/src/Unit/ValueObject/DateValueObjectTest.php diff --git a/tests/Unit/ValueObject/FileValueObjectTest.php b/tests/src/Unit/ValueObject/FileValueObjectTest.php similarity index 100% rename from tests/Unit/ValueObject/FileValueObjectTest.php rename to tests/src/Unit/ValueObject/FileValueObjectTest.php diff --git a/tests/Unit/ValueObject/GalleryItemValueObjectTest.php b/tests/src/Unit/ValueObject/GalleryItemValueObjectTest.php similarity index 100% rename from tests/Unit/ValueObject/GalleryItemValueObjectTest.php rename to tests/src/Unit/ValueObject/GalleryItemValueObjectTest.php diff --git a/tests/Unit/ValueObject/ImageValueObjectTest.php b/tests/src/Unit/ValueObject/ImageValueObjectTest.php similarity index 91% rename from tests/Unit/ValueObject/ImageValueObjectTest.php rename to tests/src/Unit/ValueObject/ImageValueObjectTest.php index a8f39fb6c..01ce4a9ff 100644 --- a/tests/Unit/ValueObject/ImageValueObjectTest.php +++ b/tests/src/Unit/ValueObject/ImageValueObjectTest.php @@ -118,28 +118,6 @@ public function testFromImageItem() { } -/** - * Temporary mock for file_create_url(). - * - * @see https://www.drupal.org/project/drupal/issues/2669074 - */ -if (!function_exists('Drupal\Tests\oe_theme\Unit\Patterns\file_create_url')) { - - /** - * Mock for file_create_url(). - * - * @param string $uri - * Uri to be processed. - * - * @return string - * Process url. - */ - function file_create_url($uri): string { - return $uri; - } - -} - /** * Mocking file_create_url(). * diff --git a/tests/Unit/fixtures/value_object/date_value_object.yml b/tests/src/Unit/fixtures/value_object/date_value_object.yml similarity index 100% rename from tests/Unit/fixtures/value_object/date_value_object.yml rename to tests/src/Unit/fixtures/value_object/date_value_object.yml From 1e42a327cbc2005734f40970acfe2fc8f90af3c1 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Thu, 19 Aug 2021 13:58:39 +0300 Subject: [PATCH 09/28] OEL-60: Use PHPUnit 7.5 and higher. --- composer.json | 3 ++- tests/src/PatternAssertions/BasePatternAssert.php | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 2448c06e4..ddae216e4 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,8 @@ "openeuropa/oe_contact_forms": "dev-OEL-164", "openeuropa/rdf_skos": "~1.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0", - "phpspec/prophecy-phpunit": "^1 || ^2" + "phpspec/prophecy-phpunit": "^1 || ^2", + "phpunit/phpunit": "^7.5 || ^8 || ^9" }, "_readme": [ "We explicitly require consolidation/robo to allow lower 'composer update --prefer-lowest' to complete successfully.", diff --git a/tests/src/PatternAssertions/BasePatternAssert.php b/tests/src/PatternAssertions/BasePatternAssert.php index 571a72b9a..f024991e9 100644 --- a/tests/src/PatternAssertions/BasePatternAssert.php +++ b/tests/src/PatternAssertions/BasePatternAssert.php @@ -4,7 +4,6 @@ namespace Drupal\Tests\oe_theme\PatternAssertions; -use Drupal\Tests\PhpUnitCompatibilityTrait; use PHPUnit\Framework\Assert; use PHPUnit\Framework\Exception; use Symfony\Component\DomCrawler\Crawler; @@ -14,10 +13,6 @@ */ abstract class BasePatternAssert extends Assert implements PatternAssertInterface { - // Adds support of new asserts like assertStringContainsString() for - // PHPUnit 6.5. - use PhpUnitCompatibilityTrait; - /** * Method that returns the assertions to be run by a particular pattern. * From 987824166f4cb3f0289e3052e95bffcaa746d77b Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Sat, 28 Aug 2021 12:57:00 +0300 Subject: [PATCH 10/28] OEL-60: Remove drupal/typed_link since it is used in oe_paragraphs. --- composer.json | 1 - tests/src/Kernel/Paragraphs/MediaParagraphsTest.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ddae216e4..f5d8384bf 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,6 @@ "drupal/json_field": "^1.0.0-rc2", "drupal/renderviz": "^1.0@alpha", "drupal/styleguide": "~1.0@beta", - "drupal/typed_link": "~1.1", "drush/drush": "~10.3", "easyrdf/easyrdf": "1.0.0 as 0.9.1", "friends-of-behat/service-container-extension": "^1.0", diff --git a/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php b/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php index 15c2774a3..a6f515b97 100644 --- a/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/src/Kernel/Paragraphs/MediaParagraphsTest.php @@ -44,7 +44,7 @@ protected function setUp(): void { parent::setUp(); $this->container->get('module_handler')->loadInclude('oe_paragraphs_media_field_storage', 'install'); - oe_paragraphs_media_field_storage_install(); + oe_paragraphs_media_field_storage_install(FALSE); $this->installEntitySchema('media'); $this->installConfig([ 'media', From e76113d34d04ff896b1aee621b5f09042257a39a Mon Sep 17 00:00:00 2001 From: upchuk Date: Wed, 27 Oct 2021 13:48:56 +0200 Subject: [PATCH 11/28] OEL-60: Fixing the PHPUnit batch extension. --- phpunit.xml.dist | 2 +- .../EnsurePHPUnitBatchingTestExtension.php | 26 ++++++++++++++++ .../src/EnsurePHPUnitBatchingTestListener.php | 31 ------------------- 3 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 tests/src/EnsurePHPUnitBatchingTestExtension.php delete mode 100644 tests/src/EnsurePHPUnitBatchingTestListener.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 23d103d06..ea773f57f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ - + diff --git a/tests/src/EnsurePHPUnitBatchingTestExtension.php b/tests/src/EnsurePHPUnitBatchingTestExtension.php new file mode 100644 index 000000000..d4110e501 --- /dev/null +++ b/tests/src/EnsurePHPUnitBatchingTestExtension.php @@ -0,0 +1,26 @@ +getDocComment())) { + throw new Exception("The following test has not been assigned to a test batch: " . $test); + } + } + +} diff --git a/tests/src/EnsurePHPUnitBatchingTestListener.php b/tests/src/EnsurePHPUnitBatchingTestListener.php deleted file mode 100644 index b14a52e2d..000000000 --- a/tests/src/EnsurePHPUnitBatchingTestListener.php +++ /dev/null @@ -1,31 +0,0 @@ -getGroups(); - if (empty(preg_grep('/^batch(\d+)$/', $groups))) { - $reflection = new \ReflectionClass($test); - $name = $reflection->name . '::' . $test->getName(); - throw new Exception("The following test has not been assigned to a test batch: " . $name); - } - } - } - -} From 2a5393a26bf8d273667b687c5f8108b6152ee9ab Mon Sep 17 00:00:00 2001 From: upchuk Date: Wed, 27 Oct 2021 14:24:54 +0200 Subject: [PATCH 12/28] OEL-60: Fixing test module dependencies. --- tests/src/Kernel/ConsultationRenderTest.php | 1 + tests/src/Kernel/PersonRenderTest.php | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/src/Kernel/ConsultationRenderTest.php b/tests/src/Kernel/ConsultationRenderTest.php index 9699bdd3a..c58fca636 100644 --- a/tests/src/Kernel/ConsultationRenderTest.php +++ b/tests/src/Kernel/ConsultationRenderTest.php @@ -31,6 +31,7 @@ class ConsultationRenderTest extends ContentRenderTestBase { 'composite_reference', 'oe_time_caching', 'oe_content_departments_field', + 'oe_content_sub_entity', 'oe_content_consultation', 'oe_content_sub_entity_document_reference', 'oe_theme_content_consultation', diff --git a/tests/src/Kernel/PersonRenderTest.php b/tests/src/Kernel/PersonRenderTest.php index 42931b384..42a00ea7a 100644 --- a/tests/src/Kernel/PersonRenderTest.php +++ b/tests/src/Kernel/PersonRenderTest.php @@ -39,6 +39,7 @@ class PersonRenderTest extends ContentRenderTestBase { 'oe_content_organisation', 'oe_content_organisation_reference', 'oe_content_social_media_links_field', + 'oe_content_sub_entity', 'oe_content_sub_entity_document_reference', 'oe_theme_content_organisation', 'oe_theme_content_organisation_reference', From 8947057be17f3539b90860b9a1e7f5fd6fe0121f Mon Sep 17 00:00:00 2001 From: upchuk Date: Fri, 29 Oct 2021 13:32:34 +0200 Subject: [PATCH 13/28] OEL-60: Fixing frontpage Views title in test. --- tests/src/Functional/BreadcrumbTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/src/Functional/BreadcrumbTest.php b/tests/src/Functional/BreadcrumbTest.php index 0a5ab9f2a..fcdb72899 100644 --- a/tests/src/Functional/BreadcrumbTest.php +++ b/tests/src/Functional/BreadcrumbTest.php @@ -4,6 +4,8 @@ namespace Drupal\Tests\oe_theme\Functional; +use Drupal\views\Entity\View; + /** * Tests that breadcrumbs are cached correctly. * @@ -23,6 +25,20 @@ class BreadcrumbTest extends ContentRenderTestBase { 'block', ]; + /** + * {@inheritdoc} + */ + protected function setUp(): void { + parent::setUp(); + + // Set the frontpage View title so it shows in the breadcrumb. + /** @var \Drupal\views\ViewEntityInterface $view */ + $view = View::load('frontpage'); + $options = &$view->getDisplay('default'); + $options['display_options']['title'] = 'Node'; + $view->save(); + } + /** * Tests that the breadcrumbs are cached correctly. */ From d29b5a0e291efeecb4abcb5540a85805d5eb3314 Mon Sep 17 00:00:00 2001 From: upchuk Date: Fri, 29 Oct 2021 14:26:59 +0200 Subject: [PATCH 14/28] OEL-60: Fixing expected oEmbed local thumbnail name. --- .../Field/FieldFormatter/MediaGalleryFormatterTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php index ede81dc31..971c8f1bc 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php @@ -218,9 +218,12 @@ public function testFormatter(): void { '/media/oembed?url=https%3A//www.youtube.com/watch%3Fv%3D1-g73ty9v04&max_width=576&max_height=400&hash=', $items->eq(1)->filter('.ecl-gallery__item-link')->attr('data-ecl-gallery-item-embed-src') ); + + $expected_thumbnail_name = version_compare(\Drupal::VERSION, '9.2', '>=') ? 'FRPRzhRHyt8zGp5-d-luvJDnIb03oXDJUp5LtL4UeDI.jpg' : 'LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg'; + $image_node = $items->eq(1)->filter('img'); $this->assertEquals("Energy, let's save it!", $image_node->attr('alt')); - $this->assertStringEndsWith('/oembed_thumbnails/LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg', $image_node->attr('src')); + $this->assertStringEndsWith('/oembed_thumbnails/' . $expected_thumbnail_name, $image_node->attr('src')); $caption = $items->eq(1)->filter('.ecl-gallery__description'); $this->assertStringContainsString($video_media->label(), $caption->html()); $this->assertEmpty($caption->filter('.ecl-gallery__meta')->html()); @@ -317,7 +320,7 @@ public function testFormatter(): void { $image_node = $items->eq(1)->filter('img'); $this->assertEquals("Energy, let's save it!", $image_node->attr('alt')); $this->assertStringContainsString( - '/files/styles/medium/public/oembed_thumbnails/LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg?itok=', + '/files/styles/medium/public/oembed_thumbnails/' . $expected_thumbnail_name . '?itok=', $image_node->attr('src') ); $caption = $items->eq(1)->filter('.ecl-gallery__description'); From 508290568e4123a457541017d88cb6e32a34c7ed Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Thu, 21 Oct 2021 20:16:11 +0300 Subject: [PATCH 15/28] EWPP-1649: Update ECL version to 3.1.1. --- package.json | 90 +++++++++---------- ....patch => twig-component-card+3.1.1.patch} | 6 +- ...component-footer-standardised+3.1.1.patch} | 0 ...patch => twig-component-table+3.1.1.patch} | 0 4 files changed, 48 insertions(+), 48 deletions(-) rename patches/@ecl/{twig-component-card+3.0.3.patch => twig-component-card+3.1.1.patch} (88%) rename patches/@ecl/{twig-component-footer-standardised+3.0.3.patch => twig-component-footer-standardised+3.1.1.patch} (100%) rename patches/@ecl/{twig-component-table+3.0.3.patch => twig-component-table+3.1.1.patch} (100%) diff --git a/package.json b/package.json index c4a9e0b51..8b5b1a3f1 100644 --- a/package.json +++ b/package.json @@ -14,52 +14,52 @@ "prepare": "patch-package" }, "dependencies": { - "@ecl/builder": "3.0.3", - "@ecl/twig-component-accordion": "3.0.3", - "@ecl/twig-component-blockquote": "3.0.3", - "@ecl/twig-component-breadcrumb-core": "3.0.3", - "@ecl/twig-component-breadcrumb-standardised": "3.0.3", - "@ecl/twig-component-button": "3.0.3", - "@ecl/twig-component-card": "3.0.3", - "@ecl/twig-component-description-list": "3.0.3", - "@ecl/twig-component-expandable": "3.0.3", - "@ecl/twig-component-fact-figures": "3.0.3", - "@ecl/twig-component-file": "3.0.3", - "@ecl/twig-component-footer-core": "3.0.3", - "@ecl/twig-component-footer-standardised": "3.0.3", - "@ecl/twig-component-gallery": "3.0.3", - "@ecl/twig-component-hero-banner": "3.0.3", - "@ecl/twig-component-icon": "3.0.3", - "@ecl/twig-component-inpage-navigation": "3.0.3", - "@ecl/twig-component-language-list": "3.0.3", - "@ecl/twig-component-link": "3.0.3", - "@ecl/twig-component-media-container": "3.0.3", - "@ecl/twig-component-menu": "3.0.3", - "@ecl/twig-component-message": "3.0.3", - "@ecl/twig-component-page-banner": "3.0.3", - "@ecl/twig-component-page-header-core": "3.0.3", - "@ecl/twig-component-page-header-standardised": "3.0.3", - "@ecl/twig-component-pagination": "3.0.3", - "@ecl/twig-component-radio": "3.0.3", - "@ecl/twig-component-search-form": "3.0.3", - "@ecl/twig-component-site-header-core": "3.0.3", - "@ecl/twig-component-site-header-standardised": "3.0.3", - "@ecl/twig-component-skip-link": "3.0.3", - "@ecl/twig-component-social-media-follow": "3.0.3", - "@ecl/twig-component-social-media-share": "3.0.3", - "@ecl/twig-component-table": "3.0.3", - "@ecl/twig-component-tag": "3.0.3", - "@ecl/twig-component-text-input": "3.0.3", - "@ecl/twig-component-timeline": "3.0.3", - "@ecl/twig-component-datepicker": "3.0.3", - "@ecl/preset-reset": "3.0.3", - "@ecl/preset-ec": "3.0.3", - "@ecl/preset-eu": "3.0.3", - "@ecl/theme-ec": "3.0.3", - "@ecl/theme-eu": "3.0.3", - "@ecl/vanilla-utility-background": "3.0.3", - "@ecl/vanilla-utility-border": "3.0.3", + "@ecl/builder": "3.1.1", + "@ecl/preset-ec": "3.1.1", + "@ecl/preset-eu": "3.1.1", + "@ecl/preset-reset": "3.1.1", "@ecl/stylelint-config": "0.2.1", + "@ecl/theme-ec": "3.1.1", + "@ecl/theme-eu": "3.1.1", + "@ecl/twig-component-accordion": "3.1.1", + "@ecl/twig-component-blockquote": "3.1.1", + "@ecl/twig-component-breadcrumb-core": "3.1.1", + "@ecl/twig-component-breadcrumb-standardised": "3.1.1", + "@ecl/twig-component-button": "3.1.1", + "@ecl/twig-component-card": "3.1.1", + "@ecl/twig-component-datepicker": "3.1.1", + "@ecl/twig-component-description-list": "3.1.1", + "@ecl/twig-component-expandable": "3.1.1", + "@ecl/twig-component-fact-figures": "3.1.1", + "@ecl/twig-component-file": "3.1.1", + "@ecl/twig-component-footer-core": "3.1.1", + "@ecl/twig-component-footer-standardised": "3.1.1", + "@ecl/twig-component-gallery": "3.1.1", + "@ecl/twig-component-hero-banner": "3.1.1", + "@ecl/twig-component-icon": "3.1.1", + "@ecl/twig-component-inpage-navigation": "3.1.1", + "@ecl/twig-component-language-list": "3.1.1", + "@ecl/twig-component-link": "3.1.1", + "@ecl/twig-component-media-container": "3.1.1", + "@ecl/twig-component-menu": "3.1.1", + "@ecl/twig-component-message": "3.1.1", + "@ecl/twig-component-page-banner": "3.1.1", + "@ecl/twig-component-page-header-core": "3.1.1", + "@ecl/twig-component-page-header-standardised": "3.1.1", + "@ecl/twig-component-pagination": "3.1.1", + "@ecl/twig-component-radio": "3.1.1", + "@ecl/twig-component-search-form": "3.1.1", + "@ecl/twig-component-site-header-core": "3.1.1", + "@ecl/twig-component-site-header-standardised": "3.1.1", + "@ecl/twig-component-skip-link": "3.1.1", + "@ecl/twig-component-social-media-follow": "3.1.1", + "@ecl/twig-component-social-media-share": "3.1.1", + "@ecl/twig-component-table": "3.1.1", + "@ecl/twig-component-tag": "3.1.1", + "@ecl/twig-component-text-input": "3.1.1", + "@ecl/twig-component-timeline": "3.1.1", + "@ecl/vanilla-utility-background": "3.1.1", + "@ecl/vanilla-utility-border": "3.1.1", "chokidar-cli": "1.2.0", "grunt": "^1.4.0", "grunt-contrib-copy": "^1.0.0", diff --git a/patches/@ecl/twig-component-card+3.0.3.patch b/patches/@ecl/twig-component-card+3.1.1.patch similarity index 88% rename from patches/@ecl/twig-component-card+3.0.3.patch rename to patches/@ecl/twig-component-card+3.1.1.patch index 692770ac0..b8298ca68 100644 --- a/patches/@ecl/twig-component-card+3.0.3.patch +++ b/patches/@ecl/twig-component-card+3.1.1.patch @@ -1,9 +1,9 @@ patch-package --- a/node_modules/@ecl/twig-component-card/card.html.twig +++ b/node_modules/@ecl/twig-component-card/card.html.twig -@@ -99,7 +99,7 @@ - -
+@@ -112,7 +112,7 @@ + + {% endif %} {% if _card.meta is not empty %} -
{{ _card.meta|join(" | ") }}
+
{{ _card.meta|safe_join(" | ") }}
diff --git a/patches/@ecl/twig-component-footer-standardised+3.0.3.patch b/patches/@ecl/twig-component-footer-standardised+3.1.1.patch similarity index 100% rename from patches/@ecl/twig-component-footer-standardised+3.0.3.patch rename to patches/@ecl/twig-component-footer-standardised+3.1.1.patch diff --git a/patches/@ecl/twig-component-table+3.0.3.patch b/patches/@ecl/twig-component-table+3.1.1.patch similarity index 100% rename from patches/@ecl/twig-component-table+3.0.3.patch rename to patches/@ecl/twig-component-table+3.1.1.patch From cfa94efb18ad0f2435f25bd4cc421494a0ce0f2b Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Fri, 22 Oct 2021 14:31:33 +0300 Subject: [PATCH 16/28] EWPP-1649: Apply changes in site header regarding sitename. --- behat.yml.dist | 2 +- templates/layout/page--ecl-branding--standardised.html.twig | 4 +++- tests/features/theme-showcase.feature | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 94fafa961..8028e8bd8 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -37,7 +37,7 @@ default: priorities dropdown menu: ".ecl-menu__item:nth-child(3) .ecl-menu__mega" search form: ".ecl-search-form" navigation menu: ".ecl-menu" - site name: ".ecl-menu__site-name" + site name: ".ecl-site-header-standardised__site-name" pages: content management: "/en/admin/content" ECL components overview: "/en/components" diff --git a/templates/layout/page--ecl-branding--standardised.html.twig b/templates/layout/page--ecl-branding--standardised.html.twig index 4d8dc60d3..b89f5a356 100644 --- a/templates/layout/page--ecl-branding--standardised.html.twig +++ b/templates/layout/page--ecl-branding--standardised.html.twig @@ -18,7 +18,9 @@ {% block navigation %}
-
{{ site_name }}
+
+
{{ site_name }}
+
{{ parent() }} {% endblock %} diff --git a/tests/features/theme-showcase.feature b/tests/features/theme-showcase.feature index 1c7112fd8..8f34e298e 100644 --- a/tests/features/theme-showcase.feature +++ b/tests/features/theme-showcase.feature @@ -10,7 +10,7 @@ Feature: Theme showcase And I should see the "search form" element in the "header" And I should see the "language switcher" element in the "header" And I should see the "navigation menu" element in the "header" - And I should see the "site name" element in the "navigation" + And I should see the "site name" element in the "header" Scenario: The demo site navigation features placeholder menu links When I am on the homepage From b0482ed1ab938fe9649c0c144fdfa3660404eac0 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Fri, 22 Oct 2021 15:36:35 +0300 Subject: [PATCH 17/28] EWPP-1649: Fix Kernel tests. --- .../oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php | 2 +- tests/src/Kernel/Paragraphs/ParagraphsTest.php | 4 ++-- tests/src/Kernel/fixtures/rendering.yml | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index 6e7c73f54..15fa790e7 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php @@ -202,7 +202,7 @@ public function smartTrimFilterDataProvider(): array { ], 'assertions' => [ 'contains' => [ - '

Lorem ipsum dolor sit...

', + '

Lorem ipsum dolor sit...

', ], ], ], diff --git a/tests/src/Kernel/Paragraphs/ParagraphsTest.php b/tests/src/Kernel/Paragraphs/ParagraphsTest.php index 16515b5f0..47ce5e18a 100644 --- a/tests/src/Kernel/Paragraphs/ParagraphsTest.php +++ b/tests/src/Kernel/Paragraphs/ParagraphsTest.php @@ -130,10 +130,10 @@ public function testQuote(array $data, array $expected): void { $crawler = new Crawler($html); - $actual = $crawler->filter('blockquote.ecl-blockquote .ecl-blockquote__body')->html(); + $actual = $crawler->filter('figure.ecl-blockquote .ecl-blockquote__body blockquote.ecl-blockquote__quote p.ecl-blockquote__citation')->html(); $this->assertEquals($expected['body'], trim($actual)); - $actual = $crawler->filter('blockquote.ecl-blockquote footer.ecl-blockquote__attribution cite.ecl-blockquote__author')->text(); + $actual = $crawler->filter('figure.ecl-blockquote footer.ecl-blockquote__attribution cite.ecl-blockquote__author')->text(); $this->assertEquals($expected['attribution'], trim($actual)); } diff --git a/tests/src/Kernel/fixtures/rendering.yml b/tests/src/Kernel/fixtures/rendering.yml index a187b2a56..3f5d23ebb 100644 --- a/tests/src/Kernel/fixtures/rendering.yml +++ b/tests/src/Kernel/fixtures/rendering.yml @@ -1715,7 +1715,7 @@ assertions: equals: '.ecl-blockquote__author': "Quote author" - '.ecl-blockquote__body': "Quote text" + '.ecl-blockquote__citation': "Quote text" - array: '#type': pattern '#id': context_nav @@ -2029,7 +2029,7 @@ length: 25 assertions: equals: - 'div.ecl-card__description': '

Lorem ipsum dolor sit...

' + 'div.ecl-card__description': '

Lorem ipsum dolor sit...

' - array: '#type': pattern '#id': featured_item @@ -2620,7 +2620,6 @@ assertions: contains: '.ecl-menu__open': "Menu" - '.ecl-menu__site-name': "Site name" '.ecl-menu__inner-header button.ecl-menu__close .ecl-button__label': "Close" '.ecl-menu__inner-header button.ecl-menu__back .ecl-button__label': "Back" 'li.ecl-menu__item:nth-child(1) a.ecl-menu__link': "Parent 1" From 1a021ea4498fa6c830f19117433be4f9a1693341 Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Fri, 22 Oct 2021 15:41:06 +0300 Subject: [PATCH 18/28] EWPP-1649: Fix tests related to datepicker. --- tests/src/FunctionalJavascript/JavascriptBehavioursTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php b/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php index 9a3f1c779..90a9d7973 100644 --- a/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php +++ b/tests/src/FunctionalJavascript/JavascriptBehavioursTest.php @@ -153,13 +153,13 @@ public function testEclDatePicker(): void { // Assert days are present. $headers = $rows['0']->findAll('css', 'th'); $expected = [ - 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', + 'Sun', ]; foreach ($headers as $key => $column) { From 3895ad3421db422de75ee8385ab2fe26d44ff89f Mon Sep 17 00:00:00 2001 From: Sergii Pavlenko Date: Mon, 25 Oct 2021 15:28:09 +0300 Subject: [PATCH 19/28] EWPP-1649: Apply ECL 3.1.2 version. --- composer.json | 2 +- package.json | 90 +++++++++---------- ....patch => twig-component-card+3.1.2.patch} | 0 ...component-footer-standardised+3.1.2.patch} | 0 ...patch => twig-component-table+3.1.2.patch} | 0 tests/src/Kernel/ConsultationRenderTest.php | 1 + tests/src/Kernel/PersonRenderTest.php | 1 + 7 files changed, 48 insertions(+), 46 deletions(-) rename patches/@ecl/{twig-component-card+3.1.1.patch => twig-component-card+3.1.2.patch} (100%) rename patches/@ecl/{twig-component-footer-standardised+3.1.1.patch => twig-component-footer-standardised+3.1.2.patch} (100%) rename patches/@ecl/{twig-component-table+3.1.1.patch => twig-component-table+3.1.2.patch} (100%) diff --git a/composer.json b/composer.json index 18f3d1c2e..13cec5bfc 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "openeuropa/behat-transformation-context": "~0.1", "openeuropa/code-review": "~1.6", "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", - "openeuropa/oe_content": "~2.5", + "openeuropa/oe_content": "~2.6", "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", diff --git a/package.json b/package.json index 8b5b1a3f1..55257a0dd 100644 --- a/package.json +++ b/package.json @@ -14,52 +14,52 @@ "prepare": "patch-package" }, "dependencies": { - "@ecl/builder": "3.1.1", - "@ecl/preset-ec": "3.1.1", - "@ecl/preset-eu": "3.1.1", - "@ecl/preset-reset": "3.1.1", + "@ecl/builder": "3.1.2", + "@ecl/preset-ec": "3.1.2", + "@ecl/preset-eu": "3.1.2", + "@ecl/preset-reset": "3.1.2", "@ecl/stylelint-config": "0.2.1", - "@ecl/theme-ec": "3.1.1", - "@ecl/theme-eu": "3.1.1", - "@ecl/twig-component-accordion": "3.1.1", - "@ecl/twig-component-blockquote": "3.1.1", - "@ecl/twig-component-breadcrumb-core": "3.1.1", - "@ecl/twig-component-breadcrumb-standardised": "3.1.1", - "@ecl/twig-component-button": "3.1.1", - "@ecl/twig-component-card": "3.1.1", - "@ecl/twig-component-datepicker": "3.1.1", - "@ecl/twig-component-description-list": "3.1.1", - "@ecl/twig-component-expandable": "3.1.1", - "@ecl/twig-component-fact-figures": "3.1.1", - "@ecl/twig-component-file": "3.1.1", - "@ecl/twig-component-footer-core": "3.1.1", - "@ecl/twig-component-footer-standardised": "3.1.1", - "@ecl/twig-component-gallery": "3.1.1", - "@ecl/twig-component-hero-banner": "3.1.1", - "@ecl/twig-component-icon": "3.1.1", - "@ecl/twig-component-inpage-navigation": "3.1.1", - "@ecl/twig-component-language-list": "3.1.1", - "@ecl/twig-component-link": "3.1.1", - "@ecl/twig-component-media-container": "3.1.1", - "@ecl/twig-component-menu": "3.1.1", - "@ecl/twig-component-message": "3.1.1", - "@ecl/twig-component-page-banner": "3.1.1", - "@ecl/twig-component-page-header-core": "3.1.1", - "@ecl/twig-component-page-header-standardised": "3.1.1", - "@ecl/twig-component-pagination": "3.1.1", - "@ecl/twig-component-radio": "3.1.1", - "@ecl/twig-component-search-form": "3.1.1", - "@ecl/twig-component-site-header-core": "3.1.1", - "@ecl/twig-component-site-header-standardised": "3.1.1", - "@ecl/twig-component-skip-link": "3.1.1", - "@ecl/twig-component-social-media-follow": "3.1.1", - "@ecl/twig-component-social-media-share": "3.1.1", - "@ecl/twig-component-table": "3.1.1", - "@ecl/twig-component-tag": "3.1.1", - "@ecl/twig-component-text-input": "3.1.1", - "@ecl/twig-component-timeline": "3.1.1", - "@ecl/vanilla-utility-background": "3.1.1", - "@ecl/vanilla-utility-border": "3.1.1", + "@ecl/theme-ec": "3.1.2", + "@ecl/theme-eu": "3.1.2", + "@ecl/twig-component-accordion": "3.1.2", + "@ecl/twig-component-blockquote": "3.1.2", + "@ecl/twig-component-breadcrumb-core": "3.1.2", + "@ecl/twig-component-breadcrumb-standardised": "3.1.2", + "@ecl/twig-component-button": "3.1.2", + "@ecl/twig-component-card": "3.1.2", + "@ecl/twig-component-datepicker": "3.1.2", + "@ecl/twig-component-description-list": "3.1.2", + "@ecl/twig-component-expandable": "3.1.2", + "@ecl/twig-component-fact-figures": "3.1.2", + "@ecl/twig-component-file": "3.1.2", + "@ecl/twig-component-footer-core": "3.1.2", + "@ecl/twig-component-footer-standardised": "3.1.2", + "@ecl/twig-component-gallery": "3.1.2", + "@ecl/twig-component-hero-banner": "3.1.2", + "@ecl/twig-component-icon": "3.1.2", + "@ecl/twig-component-inpage-navigation": "3.1.2", + "@ecl/twig-component-language-list": "3.1.2", + "@ecl/twig-component-link": "3.1.2", + "@ecl/twig-component-media-container": "3.1.2", + "@ecl/twig-component-menu": "3.1.2", + "@ecl/twig-component-message": "3.1.2", + "@ecl/twig-component-page-banner": "3.1.2", + "@ecl/twig-component-page-header-core": "3.1.2", + "@ecl/twig-component-page-header-standardised": "3.1.2", + "@ecl/twig-component-pagination": "3.1.2", + "@ecl/twig-component-radio": "3.1.2", + "@ecl/twig-component-search-form": "3.1.2", + "@ecl/twig-component-site-header-core": "3.1.2", + "@ecl/twig-component-site-header-standardised": "3.1.2", + "@ecl/twig-component-skip-link": "3.1.2", + "@ecl/twig-component-social-media-follow": "3.1.2", + "@ecl/twig-component-social-media-share": "3.1.2", + "@ecl/twig-component-table": "3.1.2", + "@ecl/twig-component-tag": "3.1.2", + "@ecl/twig-component-text-input": "3.1.2", + "@ecl/twig-component-timeline": "3.1.2", + "@ecl/vanilla-utility-background": "3.1.2", + "@ecl/vanilla-utility-border": "3.1.2", "chokidar-cli": "1.2.0", "grunt": "^1.4.0", "grunt-contrib-copy": "^1.0.0", diff --git a/patches/@ecl/twig-component-card+3.1.1.patch b/patches/@ecl/twig-component-card+3.1.2.patch similarity index 100% rename from patches/@ecl/twig-component-card+3.1.1.patch rename to patches/@ecl/twig-component-card+3.1.2.patch diff --git a/patches/@ecl/twig-component-footer-standardised+3.1.1.patch b/patches/@ecl/twig-component-footer-standardised+3.1.2.patch similarity index 100% rename from patches/@ecl/twig-component-footer-standardised+3.1.1.patch rename to patches/@ecl/twig-component-footer-standardised+3.1.2.patch diff --git a/patches/@ecl/twig-component-table+3.1.1.patch b/patches/@ecl/twig-component-table+3.1.2.patch similarity index 100% rename from patches/@ecl/twig-component-table+3.1.1.patch rename to patches/@ecl/twig-component-table+3.1.2.patch diff --git a/tests/src/Kernel/ConsultationRenderTest.php b/tests/src/Kernel/ConsultationRenderTest.php index c58fca636..ce3ed8222 100644 --- a/tests/src/Kernel/ConsultationRenderTest.php +++ b/tests/src/Kernel/ConsultationRenderTest.php @@ -36,6 +36,7 @@ class ConsultationRenderTest extends ContentRenderTestBase { 'oe_content_sub_entity_document_reference', 'oe_theme_content_consultation', 'datetime_testing', + 'oe_content_sub_entity', ]; /** diff --git a/tests/src/Kernel/PersonRenderTest.php b/tests/src/Kernel/PersonRenderTest.php index 42a00ea7a..b06ae2621 100644 --- a/tests/src/Kernel/PersonRenderTest.php +++ b/tests/src/Kernel/PersonRenderTest.php @@ -45,6 +45,7 @@ class PersonRenderTest extends ContentRenderTestBase { 'oe_theme_content_organisation_reference', 'oe_theme_content_person', 'description_list_field', + 'oe_content_sub_entity', ]; /** From 6e23e54db3d118e1bab63cde54c4605640f16c43 Mon Sep 17 00:00:00 2001 From: Imanol Eguskiza Date: Fri, 29 Oct 2021 13:18:07 +0200 Subject: [PATCH 20/28] Prepare release 3.0.0-beta5. --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a14c065..bb41f5c62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,22 @@ # Changelog +## [3.0.0-beta5](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta5) (2021-10-29) + +[Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta4...3.0.0-beta5) + +**Merged pull requests:** + +- EWPP-1649: Update ECL version. [\#968](https://github.com/openeuropa/oe_theme/pull/968) ([sergepavle](https://github.com/sergepavle)) +- EWPP-1432: Update field_group module to 3.2. [\#923](https://github.com/openeuropa/oe_theme/pull/923) ([yenyasinn](https://github.com/yenyasinn)) +- EWPP-1579: Update to ECL 3.0.3. [\#953](https://github.com/openeuropa/oe_theme/pull/953) ([22Alexandra](https://github.com/22Alexandra)) + ## [3.0.0-beta4](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta4) (2021-09-27) [Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta3...3.0.0-beta4) **Merged pull requests:** +- Prepare release 3.0.0-beta4. [\#961](https://github.com/openeuropa/oe_theme/pull/961) ([imanoleguskiza](https://github.com/imanoleguskiza)) - Epic ewpp 1360 news v3 [\#957](https://github.com/openeuropa/oe_theme/pull/957) ([22Alexandra](https://github.com/22Alexandra)) - Update epic news [\#956](https://github.com/openeuropa/oe_theme/pull/956) ([22Alexandra](https://github.com/22Alexandra)) - EWPP-1486: Theme publication collection related fields. [\#945](https://github.com/openeuropa/oe_theme/pull/945) ([nagyad](https://github.com/nagyad)) From d423f6085dd3ee0771775fe289075900b883161f Mon Sep 17 00:00:00 2001 From: Imanol Eguskiza Date: Mon, 8 Nov 2021 14:30:21 +0100 Subject: [PATCH 21/28] Prepare release 3.0.0-alpha6. --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb41f5c62..05d2f4747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,20 @@ # Changelog +## [3.0.0-beta5](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta6) (2021-11-08) + +[Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta5...3.0.0-beta6) + +**Merged pull requests:** + +- OEL-60: Drupal 9 Compatibility fixes. [\#880](https://github.com/openeuropa/oe_theme/pull/880) ([escuriola](https://github.com/escuriola)) + ## [3.0.0-beta5](https://github.com/openeuropa/oe_theme/tree/3.0.0-beta5) (2021-10-29) [Full Changelog](https://github.com/openeuropa/oe_theme/compare/3.0.0-beta4...3.0.0-beta5) **Merged pull requests:** +- Prepare release 3.0.0-beta5. [\#975](https://github.com/openeuropa/oe_theme/pull/975) ([imanoleguskiza](https://github.com/imanoleguskiza)) - EWPP-1649: Update ECL version. [\#968](https://github.com/openeuropa/oe_theme/pull/968) ([sergepavle](https://github.com/sergepavle)) - EWPP-1432: Update field_group module to 3.2. [\#923](https://github.com/openeuropa/oe_theme/pull/923) ([yenyasinn](https://github.com/yenyasinn)) - EWPP-1579: Update to ECL 3.0.3. [\#953](https://github.com/openeuropa/oe_theme/pull/953) ([22Alexandra](https://github.com/22Alexandra)) From 21e6c75e7ccec415dcc1d5339b1a98ba289ab29d Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Mon, 25 Oct 2021 17:26:10 +0300 Subject: [PATCH 22/28] EWPP-1050: Show Turkey address correctly. --- .../Field/FieldFormatter/AddressInlineFormatter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php b/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php index 576a04cbf..957348608 100644 --- a/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php +++ b/modules/oe_theme_helper/src/Plugin/Field/FieldFormatter/AddressInlineFormatter.php @@ -100,7 +100,13 @@ protected function viewElement(AddressInterface $address, $langcode) { else { $format_string = $address_format->getFormat() . "\n" . '%country'; } - $format_string = str_replace([',', ' - '], "\n", $format_string); + /* + * Remove extra characters from address format since address fields are + * optional. + * + * @see \CommerceGuys\Addressing\AddressFormat\AddressFormatRepository::getDefinitions() + */ + $format_string = str_replace([',', ' - ', '/'], "\n", $format_string); $items = $this->extractAddressItems($format_string, $address_elements); From d1e1ca9c9f3866a2774e67513f3ff240f19985af Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Fri, 24 Sep 2021 18:25:28 +0300 Subject: [PATCH 23/28] EWPP-1557: Translate "@date in" to Arabic and Turkish languages. --- ..._call_proposals_publication_info.html.twig | 6 +-- .../src/TwigExtension/TwigExtension.php | 14 +++++++ .../tests/src/Kernel/TwigExtensionTest.php | 41 +++++++++++++++++++ .../translations/oe_theme_helper-ar.po | 4 ++ .../translations/oe_theme_helper-bg.po | 4 +- .../translations/oe_theme_helper-ca.po | 4 +- .../translations/oe_theme_helper-cs.po | 4 +- .../translations/oe_theme_helper-da.po | 4 +- .../translations/oe_theme_helper-de.po | 4 +- .../translations/oe_theme_helper-el.po | 4 +- .../translations/oe_theme_helper-es.po | 4 +- .../translations/oe_theme_helper-et.po | 4 +- .../translations/oe_theme_helper-fi.po | 4 +- .../translations/oe_theme_helper-fr.po | 4 +- .../translations/oe_theme_helper-ga.po | 4 +- .../translations/oe_theme_helper-hr.po | 4 +- .../translations/oe_theme_helper-hu.po | 4 +- .../translations/oe_theme_helper-is.po | 4 +- .../translations/oe_theme_helper-it.po | 4 +- .../translations/oe_theme_helper-lt.po | 4 +- .../translations/oe_theme_helper-lv.po | 4 +- .../translations/oe_theme_helper-mt.po | 4 +- .../translations/oe_theme_helper-nb.po | 4 +- .../translations/oe_theme_helper-nl.po | 4 +- .../translations/oe_theme_helper-pl.po | 4 +- .../translations/oe_theme_helper-pt-pt.po | 4 +- .../translations/oe_theme_helper-ro.po | 4 +- .../translations/oe_theme_helper-sk.po | 4 +- .../translations/oe_theme_helper-sl.po | 4 +- .../translations/oe_theme_helper-sv.po | 4 +- .../translations/oe_theme_helper-tr.po | 3 ++ 31 files changed, 117 insertions(+), 55 deletions(-) diff --git a/modules/oe_theme_content_call_proposals/templates/oe_theme_content_call_proposals_publication_info.html.twig b/modules/oe_theme_content_call_proposals/templates/oe_theme_content_call_proposals_publication_info.html.twig index 92baedc47..bf013d723 100644 --- a/modules/oe_theme_content_call_proposals/templates/oe_theme_content_call_proposals_publication_info.html.twig +++ b/modules/oe_theme_content_call_proposals/templates/oe_theme_content_call_proposals_publication_info.html.twig @@ -10,7 +10,7 @@ {{ date }} {% else %} {% set _link %} - {% include '@ecl-twig/link' with { + {%- include '@ecl-twig/link' with { link: { type: 'standalone', label: link.title, @@ -18,7 +18,7 @@ icon_position: 'after' }, icon: get_link_icon(link.url) - } %} + } -%} {% endset %} - {{ '@date in'|t({'@date': date }) }} {{ _link }} + {{ '@date in @journal'|t({'@date': date, '@journal': _link|create_markup}) }} {% endif %} diff --git a/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php b/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php index 54874f939..21574fba6 100644 --- a/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php +++ b/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php @@ -73,6 +73,7 @@ public function getFilters(): array { new TwigFilter('smart_trim', [$this, 'smartTrim'], ['needs_environment' => TRUE]), new TwigFilter('is_external_url', [UrlHelper::class, 'isExternal']), new TwigFilter('filter_empty', [$this, 'filterEmpty']), + new TwigFilter('create_markup', [$this, 'createMarkup']), ]; } @@ -703,4 +704,17 @@ public function eclFooterLinks(array $context, array $links): array { return $ecl_links; } + /** + * Creates a Markup object. + * + * @param mixed $string + * The string to mark as safe. This value will be cast to a string. + * + * @return \Drupal\Component\Render\MarkupInterface + * A safe string. + */ + public function createMarkup($string): MarkupInterface { + return Markup::create($string); + } + } diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index 15fa790e7..9fab13805 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php @@ -209,4 +209,45 @@ public function smartTrimFilterDataProvider(): array { ]; } + /** + * Test create_markup filter. + */ + public function testCreateMarkup() { + // Twig escapes strings from the variable by default. + $render_string = [ + '#type' => 'inline_template', + '#template' => '{{ content }}', + '#context' => [ + 'content' => 'This a string with the link', + ], + ]; + $result = $this->renderElements($render_string); + $this->assertEquals('This a string with the <a href="http://www.example.com">link</a>', $result); + + // Twig doesn't escape Markup object. + $render_markup = [ + '#type' => 'inline_template', + '#template' => '{{ content|create_markup }}', + '#context' => [ + 'content' => 'This a string with the link', + ], + ]; + $result = $this->renderElements($render_markup); + $this->assertEquals('This a string with the link', $result); + } + + /** + * Renders HTML given a structured array tree. + * + * @param array $elements + * The structured array describing the data to be rendered. + */ + protected function renderElements(array $elements) { + $context = new RenderContext(); + $renderer = $this->container->get('renderer'); + return $renderer->executeInRenderContext($context, function () use (&$elements, $renderer) { + return (string) $renderer->render($elements); + }); + } + } diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ar.po b/modules/oe_theme_helper/translations/oe_theme_helper-ar.po index ccb7c689a..add4fdfdd 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ar.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ar.po @@ -520,8 +520,12 @@ msgstr "محتويات الصفحة" msgid "Name" msgstr "الاسم" +msgid "@date in @journal" +msgstr "@journal في @date" + msgid "I have read and agree with the @link" msgstr "قرأت شر @link وأوافق عليها" msgid "data protection terms" msgstr "وط حماية البيانات" + diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-bg.po b/modules/oe_theme_helper/translations/oe_theme_helper-bg.po index 810deffa1..217c50473 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-bg.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-bg.po @@ -229,8 +229,8 @@ msgstr "Няколко крайни срока" msgid "Permanent" msgstr "Постоянен" -msgid "@date in" -msgstr "@date в" +msgid "@date in @journal" +msgstr "@date в @journal" msgid "Contact us" msgstr "За контакти" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ca.po b/modules/oe_theme_helper/translations/oe_theme_helper-ca.po index 560dfa6ed..7ff922e60 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ca.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ca.po @@ -520,8 +520,8 @@ msgstr "Contingut de la pàgina" msgid "Name" msgstr "Nom" -msgid "@date in" -msgstr "@date en" +msgid "@date in @journal" +msgstr "@date en @journal" msgid "I have read and agree with the @link" msgstr "He llegit la @link i accepto les condicions" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-cs.po b/modules/oe_theme_helper/translations/oe_theme_helper-cs.po index 45c675c6d..f542fd462 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-cs.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-cs.po @@ -229,8 +229,8 @@ msgstr "Několik termínů" msgid "Permanent" msgstr "Stálý" -msgid "@date in" -msgstr "@date v" +msgid "@date in @journal" +msgstr "@date v @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-da.po b/modules/oe_theme_helper/translations/oe_theme_helper-da.po index 4ec993799..a1f5a8e0f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-da.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-da.po @@ -229,8 +229,8 @@ msgstr "Flere faser" msgid "Permanent" msgstr "Permanent" -msgid "@date in" -msgstr "@date i" +msgid "@date in @journal" +msgstr "@date i @journal" msgid "Contact us" msgstr "Kontakt os" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-de.po b/modules/oe_theme_helper/translations/oe_theme_helper-de.po index a12c75d57..c179602c0 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-de.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-de.po @@ -229,8 +229,8 @@ msgstr "Mehrere Enddaten" msgid "Permanent" msgstr "Unbefristet" -msgid "@date in" -msgstr "@date im" +msgid "@date in @journal" +msgstr "@date im @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-el.po b/modules/oe_theme_helper/translations/oe_theme_helper-el.po index 30684075f..bea0ffaa1 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-el.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-el.po @@ -229,8 +229,8 @@ msgstr "Πολλές ημερομηνίες λήξης" msgid "Permanent" msgstr "Μόνιμος" -msgid "@date in" -msgstr "@date στην" +msgid "@date in @journal" +msgstr "@date στην @journal" msgid "Contact us" msgstr "Επικοινωνήστε μαζί μας" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-es.po b/modules/oe_theme_helper/translations/oe_theme_helper-es.po index 29a593476..0b9b3c48b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-es.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-es.po @@ -229,8 +229,8 @@ msgstr "Múltiples fechas límite" msgid "Permanent" msgstr "Permanente" -msgid "@date in" -msgstr "@date en" +msgid "@date in @journal" +msgstr "@date en @journal" msgid "Contact us" msgstr "Contacto" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-et.po b/modules/oe_theme_helper/translations/oe_theme_helper-et.po index 9650faf6b..9c509e37d 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-et.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-et.po @@ -229,8 +229,8 @@ msgstr "Mitme tähtajaga" msgid "Permanent" msgstr "Alaline" -msgid "@date in" -msgstr "@date väljaandes" +msgid "@date in @journal" +msgstr "@date väljaandes @journal" msgid "Contact us" msgstr "Võtke meiega ühendust" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-fi.po b/modules/oe_theme_helper/translations/oe_theme_helper-fi.po index 1abfaa328..e16f1b536 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-fi.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-fi.po @@ -229,8 +229,8 @@ msgstr "Monivaiheinen" msgid "Permanent" msgstr "Jatkuva" -msgid "@date in" -msgstr "@date julkaisu" +msgid "@date in @journal" +msgstr "@date julkaisu @journal" msgid "Contact us" msgstr "Yhteydenotot" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-fr.po b/modules/oe_theme_helper/translations/oe_theme_helper-fr.po index ecf2111ae..a735ba664 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-fr.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-fr.po @@ -229,8 +229,8 @@ msgstr "Dates limites multiples" msgid "Permanent" msgstr "Permanent" -msgid "@date in" -msgstr "@date au" +msgid "@date in @journal" +msgstr "@date au @journal" msgid "Contact us" msgstr "Nous contacter" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po index 607164c36..7ecb56a65 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ga.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ga.po @@ -229,8 +229,8 @@ msgstr "Scoitheadh ilchéimneach" msgid "Permanent" msgstr "Buan" -msgid "@date in" -msgstr "@date sa" +msgid "@date in @journal" +msgstr "@date sa @journal" msgid "Contact us" msgstr "Sonraí teagmhála" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-hr.po b/modules/oe_theme_helper/translations/oe_theme_helper-hr.po index d1e7aefb2..c67d22e03 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-hr.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-hr.po @@ -229,8 +229,8 @@ msgstr "Više rokova" msgid "Permanent" msgstr "Stalno" -msgid "@date in" -msgstr "@date," +msgid "@date in @journal" +msgstr "@date, @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po index 8f4724e0a..6e1f01e9b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-hu.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-hu.po @@ -229,8 +229,8 @@ msgstr "Többkörös" msgid "Permanent" msgstr "Állandó" -msgid "@date in" -msgstr "@date," +msgid "@date in @journal" +msgstr "@date, @journal" msgid "Contact us" msgstr "Kapcsolatfelvétel" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-is.po b/modules/oe_theme_helper/translations/oe_theme_helper-is.po index 375527d53..2aa0e3eb5 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-is.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-is.po @@ -516,8 +516,8 @@ msgstr "Innihald síðu" msgid "Name" msgstr "Heiti" -msgid "@date in" -msgstr "@date í" +msgid "@date in @journal" +msgstr "@date í @journal" msgid "The response period for this consultation has ended. Thank you for your input." msgstr "Svarfrestur vegna þessarar ráðgjafar er liðinn. Takk fyrir þitt innlegg." diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-it.po b/modules/oe_theme_helper/translations/oe_theme_helper-it.po index 50a2456a2..72adbd3f2 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-it.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-it.po @@ -229,8 +229,8 @@ msgstr "In più fasiIn più fasi" msgid "Permanent" msgstr "Permanente" -msgid "@date in" -msgstr "@date in" +msgid "@date in @journal" +msgstr "@date in @journal" msgid "Contact us" msgstr "Contattaci" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-lt.po b/modules/oe_theme_helper/translations/oe_theme_helper-lt.po index a25b91c5f..43cfc58df 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-lt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-lt.po @@ -229,8 +229,8 @@ msgstr "Keli terminai" msgid "Permanent" msgstr "Nuolatinis" -msgid "@date in" -msgstr "@date" +msgid "@date in @journal" +msgstr "@date @journal" msgid "Contact us" msgstr "Susisiekite su mumis" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-lv.po b/modules/oe_theme_helper/translations/oe_theme_helper-lv.po index 6f2627fc8..406716979 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-lv.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-lv.po @@ -229,8 +229,8 @@ msgstr "Vairāki termiņi" msgid "Permanent" msgstr "Pastāvīgs" -msgid "@date in" -msgstr "@date" +msgid "@date in @journal" +msgstr "@date @journal" msgid "Contact us" msgstr "Sazinieties ar mums" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-mt.po b/modules/oe_theme_helper/translations/oe_theme_helper-mt.po index 48f71fc1f..d50674885 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-mt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-mt.po @@ -229,8 +229,8 @@ msgstr "Fi stadji multipli" msgid "Permanent" msgstr "Permanenti" -msgid "@date in" -msgstr "@date fi" +msgid "@date in @journal" +msgstr "@date fi @journal" msgid "Contact us" msgstr "Ikkuntattjana" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-nb.po b/modules/oe_theme_helper/translations/oe_theme_helper-nb.po index 41c6e3895..b9661236c 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-nb.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-nb.po @@ -519,8 +519,8 @@ msgstr "Sideinnhold" msgid "Name" msgstr "Navn" -msgid "@date in" -msgstr "@date i" +msgid "@date in @journal" +msgstr "@date i @journal" msgid "The response period for this consultation has ended. Thank you for your input." msgstr "Høringsfristen har utløpt. Takk for ditt bidrag." diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-nl.po b/modules/oe_theme_helper/translations/oe_theme_helper-nl.po index 45986785a..46bcf872b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-nl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-nl.po @@ -229,8 +229,8 @@ msgstr "Meerdere deadlines" msgid "Permanent" msgstr "Permanent" -msgid "@date in" -msgstr "@date in" +msgid "@date in @journal" +msgstr "@date in @journal" msgid "Contact us" msgstr "Contact" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-pl.po b/modules/oe_theme_helper/translations/oe_theme_helper-pl.po index 7879e6b75..78ff56125 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-pl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-pl.po @@ -229,8 +229,8 @@ msgstr "Więcej dat zakończenia" msgid "Permanent" msgstr "Stały" -msgid "@date in" -msgstr "@date w" +msgid "@date in @journal" +msgstr "@date w @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po b/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po index b6e226b0b..eda69712b 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-pt-pt.po @@ -229,8 +229,8 @@ msgstr "Prazos múltiplos" msgid "Permanent" msgstr "Permanente" -msgid "@date in" -msgstr "@date no" +msgid "@date in @journal" +msgstr "@date no @journal" msgid "Contact us" msgstr "Contacte-nos" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-ro.po b/modules/oe_theme_helper/translations/oe_theme_helper-ro.po index 8531bd9da..8e938655a 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-ro.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-ro.po @@ -229,8 +229,8 @@ msgstr "Cu mai multe etape" msgid "Permanent" msgstr "Permanent(ă)" -msgid "@date in" -msgstr "@date în" +msgid "@date in @journal" +msgstr "@date în @journal" msgid "Contact us" msgstr "Contactați-ne" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sk.po b/modules/oe_theme_helper/translations/oe_theme_helper-sk.po index 236f38c19..d60d53d0f 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sk.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sk.po @@ -229,8 +229,8 @@ msgstr "Viacfázový" msgid "Permanent" msgstr "Stály" -msgid "@date in" -msgstr "@date v" +msgid "@date in @journal" +msgstr "@date v @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sl.po b/modules/oe_theme_helper/translations/oe_theme_helper-sl.po index ebac2f4c1..1f4db2ecf 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sl.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sl.po @@ -229,8 +229,8 @@ msgstr "Več končnih datumov" msgid "Permanent" msgstr "Stalno" -msgid "@date in" -msgstr "@date v" +msgid "@date in @journal" +msgstr "@date v @journal" msgid "Contact us" msgstr "Kontakt" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-sv.po b/modules/oe_theme_helper/translations/oe_theme_helper-sv.po index fb2acd625..edd4972b6 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-sv.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-sv.po @@ -229,8 +229,8 @@ msgstr "Flera tidsfrister" msgid "Permanent" msgstr "Ständigt pågående" -msgid "@date in" -msgstr "@date i" +msgid "@date in @journal" +msgstr "@date i @journal" msgid "Contact us" msgstr "Kontakta oss" diff --git a/modules/oe_theme_helper/translations/oe_theme_helper-tr.po b/modules/oe_theme_helper/translations/oe_theme_helper-tr.po index 81f9b59ee..c13f60c05 100644 --- a/modules/oe_theme_helper/translations/oe_theme_helper-tr.po +++ b/modules/oe_theme_helper/translations/oe_theme_helper-tr.po @@ -523,6 +523,9 @@ msgstr "Sayfa İçeriği" msgid "Name" msgstr "İsim" +msgid "@date in @journal" +msgstr "@date tarihli @journal yayını" + msgid "I have read and agree with the @link" msgstr "@link okudum ve kabul ediyorum" From 6290fabd6c1acc849b717fc7314040d3bddd457f Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Mon, 27 Sep 2021 11:02:32 +0300 Subject: [PATCH 24/28] EWPP-1557: Remove spaces from the test string. --- tests/src/Functional/ContentCallForProposalsRenderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Functional/ContentCallForProposalsRenderTest.php b/tests/src/Functional/ContentCallForProposalsRenderTest.php index 1a12474f9..cc18be313 100644 --- a/tests/src/Functional/ContentCallForProposalsRenderTest.php +++ b/tests/src/Functional/ContentCallForProposalsRenderTest.php @@ -160,7 +160,7 @@ public function testProposalRendering(): void { ])->save(); $this->drupalGet($node->toUrl()); - $details_expected_values['items'][2]['body'] = "12 February 2020 in Official Journal Reference"; + $details_expected_values['items'][2]['body'] = "12 February 2020 in Official Journal Reference"; $field_list_assert->assertPattern($details_expected_values, $content_items[0]->getHtml()); $journal_link_selector = '//*[text() = "Publication date"]/following-sibling::dd[1]/div'; From 83e429fee783f327edadecdc69f05c8d2b16cc02 Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Tue, 5 Oct 2021 12:59:38 +0300 Subject: [PATCH 25/28] EWPP-1557: Use simple method to render element. --- .../tests/src/Kernel/TwigExtensionTest.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index 9fab13805..c55095088 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php @@ -221,7 +221,7 @@ public function testCreateMarkup() { 'content' => 'This a string with the link', ], ]; - $result = $this->renderElements($render_string); + $result = $this->container->get('renderer')->renderRoot($render_string); $this->assertEquals('This a string with the <a href="http://www.example.com">link</a>', $result); // Twig doesn't escape Markup object. @@ -232,22 +232,8 @@ public function testCreateMarkup() { 'content' => 'This a string with the link', ], ]; - $result = $this->renderElements($render_markup); + $result = $this->container->get('renderer')->renderRoot($render_markup); $this->assertEquals('This a string with the link', $result); } - /** - * Renders HTML given a structured array tree. - * - * @param array $elements - * The structured array describing the data to be rendered. - */ - protected function renderElements(array $elements) { - $context = new RenderContext(); - $renderer = $this->container->get('renderer'); - return $renderer->executeInRenderContext($context, function () use (&$elements, $renderer) { - return (string) $renderer->render($elements); - }); - } - } From 208e5f2fe4e061fcade29104889e2ace5faa957e Mon Sep 17 00:00:00 2001 From: Evgenii Nikitin Date: Wed, 13 Oct 2021 15:55:14 +0300 Subject: [PATCH 26/28] EWPP-1557: Use Unit instead of Kernel test. --- .../tests/src/Kernel/TwigExtensionTest.php | 27 ------------------- .../tests/src/Unit/TwigExtensionTest.php | 9 +++++++ 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index c55095088..15fa790e7 100644 --- a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php @@ -209,31 +209,4 @@ public function smartTrimFilterDataProvider(): array { ]; } - /** - * Test create_markup filter. - */ - public function testCreateMarkup() { - // Twig escapes strings from the variable by default. - $render_string = [ - '#type' => 'inline_template', - '#template' => '{{ content }}', - '#context' => [ - 'content' => 'This a string with the link', - ], - ]; - $result = $this->container->get('renderer')->renderRoot($render_string); - $this->assertEquals('This a string with the <a href="http://www.example.com">link</a>', $result); - - // Twig doesn't escape Markup object. - $render_markup = [ - '#type' => 'inline_template', - '#template' => '{{ content|create_markup }}', - '#context' => [ - 'content' => 'This a string with the link', - ], - ]; - $result = $this->container->get('renderer')->renderRoot($render_markup); - $this->assertEquals('This a string with the link', $result); - } - } diff --git a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php index 672a71c2d..599aa2883 100644 --- a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php @@ -4,6 +4,7 @@ namespace Drupal\Tests\oe_theme_helper\Unit; +use Drupal\Component\Render\MarkupInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Render\Renderer; @@ -361,4 +362,12 @@ public function toEclIconProvider(): array { ]; } + /** + * Test that create_markup filter returns MarkupInterface object. + */ + public function testCreateMarkup() { + $markup_object = $this->extension->createMarkup('Some string'); + $this->assertInstanceOf(MarkupInterface::class, $markup_object); + } + } From a6b1cbb77aa502c7d54e960407b4253601c5b698 Mon Sep 17 00:00:00 2001 From: upchuk Date: Sun, 24 Oct 2021 13:53:42 +0200 Subject: [PATCH 27/28] EWPP-1597: Passing icon info to the list item block button link. --- .../content-item-block.html.twig | 8 +- ...st_item_block_four_columns.ui_patterns.yml | 10 ++ ...list_item_block_one_column.ui_patterns.yml | 10 ++ ...ist_item_block_six_columns.ui_patterns.yml | 10 ++ ...t_item_block_three_columns.ui_patterns.yml | 10 ++ ...ist_item_block_two_columns.ui_patterns.yml | 10 ++ ...ern-list-item-block-four-columns.html.twig | 5 +- ...ttern-list-item-block-one-column.html.twig | 5 +- ...tern-list-item-block-six-columns.html.twig | 5 +- ...rn-list-item-block-three-columns.html.twig | 5 +- ...tern-list-item-block-two-columns.html.twig | 5 +- tests/src/Kernel/fixtures/rendering.yml | 157 ++++++++++++++++++ 12 files changed, 233 insertions(+), 7 deletions(-) diff --git a/templates/compositions/ec-component-content-item-block/content-item-block.html.twig b/templates/compositions/ec-component-content-item-block/content-item-block.html.twig index 070f0a825..eb4a88d4e 100644 --- a/templates/compositions/ec-component-content-item-block/content-item-block.html.twig +++ b/templates/compositions/ec-component-content-item-block/content-item-block.html.twig @@ -76,8 +76,12 @@ {% include '@ecl-twig/link' with { link: _button|merge({ 'type': 'standalone', - 'icon_position': 'after' - }) + }), + icon: { + 'name': _button.icon_name, + 'size': 'xs', + 'path': icon_path + } } only %}
diff --git a/templates/patterns/list_item_blocks/list_item_block_four_columns.ui_patterns.yml b/templates/patterns/list_item_blocks/list_item_block_four_columns.ui_patterns.yml index f208341a2..70ccfe7da 100644 --- a/templates/patterns/list_item_blocks/list_item_block_four_columns.ui_patterns.yml +++ b/templates/patterns/list_item_blocks/list_item_block_four_columns.ui_patterns.yml @@ -62,3 +62,13 @@ list_item_block_four_columns: label: "Button URL (A Drupal Url object)" description: "Call to action URL" preview: "#" + button_icon_name: + type: "text" + label: "Icon name" + description: "The name of the icon to place next to the link" + preview: 'list' + button_icon_position: + type: "text" + label: "Icon position" + description: "The position of the icon" + preview: 'after' diff --git a/templates/patterns/list_item_blocks/list_item_block_one_column.ui_patterns.yml b/templates/patterns/list_item_blocks/list_item_block_one_column.ui_patterns.yml index 72beb0586..137365d52 100644 --- a/templates/patterns/list_item_blocks/list_item_block_one_column.ui_patterns.yml +++ b/templates/patterns/list_item_blocks/list_item_block_one_column.ui_patterns.yml @@ -37,3 +37,13 @@ list_item_block_one_column: label: "Button URL (A Drupal Url object)" description: "Call to action URL" preview: "#" + button_icon_name: + type: "text" + label: "Icon name" + description: "The name of the icon to place next to the link" + preview: 'list' + button_icon_position: + type: "text" + label: "Icon position" + description: "The position of the icon" + preview: 'after' diff --git a/templates/patterns/list_item_blocks/list_item_block_six_columns.ui_patterns.yml b/templates/patterns/list_item_blocks/list_item_block_six_columns.ui_patterns.yml index 8dee9abe3..0c021dd81 100644 --- a/templates/patterns/list_item_blocks/list_item_block_six_columns.ui_patterns.yml +++ b/templates/patterns/list_item_blocks/list_item_block_six_columns.ui_patterns.yml @@ -39,3 +39,13 @@ list_item_block_six_columns: label: "Button URL (A Drupal Url object)" description: "Call to action URL" preview: "#" + button_icon_name: + type: "text" + label: "Icon name" + description: "The name of the icon to place next to the link" + preview: 'list' + button_icon_position: + type: "text" + label: "Icon position" + description: "The position of the icon" + preview: 'after' diff --git a/templates/patterns/list_item_blocks/list_item_block_three_columns.ui_patterns.yml b/templates/patterns/list_item_blocks/list_item_block_three_columns.ui_patterns.yml index c1e9b22da..ead44a296 100644 --- a/templates/patterns/list_item_blocks/list_item_block_three_columns.ui_patterns.yml +++ b/templates/patterns/list_item_blocks/list_item_block_three_columns.ui_patterns.yml @@ -52,3 +52,13 @@ list_item_block_three_columns: label: "Button URL (A Drupal Url object)" description: "Call to action URL" preview: "#" + button_icon_name: + type: "text" + label: "Icon name" + description: "The name of the icon to place next to the link" + preview: 'list' + button_icon_position: + type: "text" + label: "Icon position" + description: "The position of the icon" + preview: 'after' diff --git a/templates/patterns/list_item_blocks/list_item_block_two_columns.ui_patterns.yml b/templates/patterns/list_item_blocks/list_item_block_two_columns.ui_patterns.yml index 49bfe4865..2d59c4f7d 100644 --- a/templates/patterns/list_item_blocks/list_item_block_two_columns.ui_patterns.yml +++ b/templates/patterns/list_item_blocks/list_item_block_two_columns.ui_patterns.yml @@ -42,3 +42,13 @@ list_item_block_two_columns: label: "Button URL (A Drupal Url object)" description: "Call to action URL" preview: "#" + button_icon_name: + type: "text" + label: "Icon name" + description: "The name of the icon to place next to the link" + preview: 'list' + button_icon_position: + type: "text" + label: "Icon position" + description: "The position of the icon" + preview: 'after' diff --git a/templates/patterns/list_item_blocks/pattern-list-item-block-four-columns.html.twig b/templates/patterns/list_item_blocks/pattern-list-item-block-four-columns.html.twig index acd6c7b39..79255dd1a 100644 --- a/templates/patterns/list_item_blocks/pattern-list-item-block-four-columns.html.twig +++ b/templates/patterns/list_item_blocks/pattern-list-item-block-four-columns.html.twig @@ -4,6 +4,7 @@ * List item block: four columns. */ #} +{% set _button_icon_position = button_icon_position|default('after') %} {% include '@oe_theme/compositions/ec-component-content-item-block/content-item-block.html.twig' with { type: 'four', title: title, @@ -11,6 +12,8 @@ icon_path: ecl_icon_path, button: { path: button_url, - label: button_label + label: button_label, + icon_name: button_icon_name, + icon_position: _button_icon_position } } only %} diff --git a/templates/patterns/list_item_blocks/pattern-list-item-block-one-column.html.twig b/templates/patterns/list_item_blocks/pattern-list-item-block-one-column.html.twig index 56def7f90..0cb86d4f1 100644 --- a/templates/patterns/list_item_blocks/pattern-list-item-block-one-column.html.twig +++ b/templates/patterns/list_item_blocks/pattern-list-item-block-one-column.html.twig @@ -4,6 +4,7 @@ * List item block: one column. */ #} +{% set _button_icon_position = button_icon_position|default('after') %} {% include '@oe_theme/compositions/ec-component-content-item-block/content-item-block.html.twig' with { type: 'one', title: title, @@ -11,6 +12,8 @@ icon_path: ecl_icon_path, button: { path: button_url, - label: button_label + label: button_label, + icon_name: button_icon_name, + icon_position: _button_icon_position } } only %} diff --git a/templates/patterns/list_item_blocks/pattern-list-item-block-six-columns.html.twig b/templates/patterns/list_item_blocks/pattern-list-item-block-six-columns.html.twig index 0a816cce7..475a07d15 100644 --- a/templates/patterns/list_item_blocks/pattern-list-item-block-six-columns.html.twig +++ b/templates/patterns/list_item_blocks/pattern-list-item-block-six-columns.html.twig @@ -4,6 +4,7 @@ * List item block: six columns. */ #} +{% set _button_icon_position = button_icon_position|default('after') %} {% include '@oe_theme/compositions/ec-component-content-item-block/content-item-block.html.twig' with { type: 'six', title: title, @@ -11,6 +12,8 @@ icon_path: ecl_icon_path, button: { path: button_url, - label: button_label + label: button_label, + icon_name: button_icon_name, + icon_position: _button_icon_position } } only %} diff --git a/templates/patterns/list_item_blocks/pattern-list-item-block-three-columns.html.twig b/templates/patterns/list_item_blocks/pattern-list-item-block-three-columns.html.twig index 613493a53..e3f3809f1 100644 --- a/templates/patterns/list_item_blocks/pattern-list-item-block-three-columns.html.twig +++ b/templates/patterns/list_item_blocks/pattern-list-item-block-three-columns.html.twig @@ -4,6 +4,7 @@ * List item block: three columns. */ #} +{% set _button_icon_position = button_icon_position|default('after') %} {% include '@oe_theme/compositions/ec-component-content-item-block/content-item-block.html.twig' with { type: 'three', title: title, @@ -11,6 +12,8 @@ icon_path: ecl_icon_path, button: { path: button_url, - label: button_label + label: button_label, + icon_name: button_icon_name, + icon_position: _button_icon_position } } only %} diff --git a/templates/patterns/list_item_blocks/pattern-list-item-block-two-columns.html.twig b/templates/patterns/list_item_blocks/pattern-list-item-block-two-columns.html.twig index 2d29a4d10..ae01a2e80 100644 --- a/templates/patterns/list_item_blocks/pattern-list-item-block-two-columns.html.twig +++ b/templates/patterns/list_item_blocks/pattern-list-item-block-two-columns.html.twig @@ -4,6 +4,7 @@ * List item block: two columns. */ #} +{% set _button_icon_position = button_icon_position|default('after') %} {% include '@oe_theme/compositions/ec-component-content-item-block/content-item-block.html.twig' with { type: 'two', title: title, @@ -11,6 +12,8 @@ icon_path: ecl_icon_path, button: { path: button_url, - label: button_label + label: button_label, + icon_name: button_icon_name, + icon_position: _button_icon_position } } only %} diff --git a/tests/src/Kernel/fixtures/rendering.yml b/tests/src/Kernel/fixtures/rendering.yml index 3f5d23ebb..3ce5c105d 100644 --- a/tests/src/Kernel/fixtures/rendering.yml +++ b/tests/src/Kernel/fixtures/rendering.yml @@ -1277,6 +1277,8 @@ 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 0 'div.ecl-content-item-block__button': 1 'div.ecl-content-item-block__button a.ecl-link[href="http://example.com"]': 1 + 'div.ecl-content-item-block__button a.ecl-link-icon': 0 + 'div.ecl-content-item-block__button a.ecl-link--standalone svg': 0 equals: 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': "Block title" 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "Business, Economy, Euro" @@ -1307,6 +1309,7 @@ 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 0 'div.ecl-content-item-block__button': 1 'div.ecl-content-item-block__button a.ecl-link[href="http://example.com"]': 1 + 'div.ecl-content-item-block__button a.ecl-link--standalone svg': 0 equals: 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "Business, Economy, Euro" 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "EU economy, the euro, and practical information for EU businesses and entrepreneurs." @@ -1365,6 +1368,71 @@ equals: 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "Business, Economy, Euro" 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "EU economy, the euro, and practical information for EU businesses and entrepreneurs." +- array: + '#type': pattern + '#id': list_item_block_one_column + '#fields': + title: "Block title" + items: + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "Business, Economy, Euro" + detail: "EU economy, the euro, and practical information for EU businesses and entrepreneurs." + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "list" + assertions: + count: + 'div.ecl-content-item-block__title': 1 + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 1 + 'div.ecl-content-item-block__item': 1 + 'div.ecl-content-item-block__item.ecl-col-12': 1 + 'div.ecl-content-item-block__item.ecl-col-m-6': 0 + 'div.ecl-content-item-block__item.ecl-col-m-4': 0 + 'div.ecl-content-item-block__item.ecl-col-12 article.ecl-content-item': 1 + 'div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item': 0 + 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 0 + 'div.ecl-content-item-block__button': 1 + 'div.ecl-content-item-block__button a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-after[href="http://example.com"]': 1 + equals: + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': "Block title" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "Business, Economy, Euro" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "EU economy, the euro, and practical information for EU businesses and entrepreneurs." + 'a.ecl-link': 'View all' +- array: + '#type': pattern + '#id': list_item_block_one_column + '#fields': + title: "Block title" + items: + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "Business, Economy, Euro" + detail: "EU economy, the euro, and practical information for EU businesses and entrepreneurs." + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "list" + button_icon_position: "before" + assertions: + count: + 'div.ecl-content-item-block__title': 1 + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 1 + 'div.ecl-content-item-block__item': 1 + 'div.ecl-content-item-block__item.ecl-col-12': 1 + 'div.ecl-content-item-block__item.ecl-col-m-6': 0 + 'div.ecl-content-item-block__item.ecl-col-m-4': 0 + 'div.ecl-content-item-block__item.ecl-col-12 article.ecl-content-item': 1 + 'div.ecl-content-item-block__item.ecl-col-m-6 article.ecl-content-item': 0 + 'div.ecl-content-item-block__item.ecl-col-m-4 article.ecl-content-item': 0 + 'div.ecl-content-item-block__button': 1 + 'div.ecl-content-item-block__button a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-before[href="http://example.com"]': 1 + equals: + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': "Block title" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "Business, Economy, Euro" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "EU economy, the euro, and practical information for EU businesses and entrepreneurs." + 'a.ecl-link': 'View all' - array: '#type': pattern '#id': list_item_block_two_columns @@ -1396,6 +1464,42 @@ 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "Description for list item 1." 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__title': "List item 2" 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__description': "Description for list item 2." +- array: + '#type': pattern + '#id': list_item_block_two_columns + '#fields': + items: + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "List item 1" + detail: "Description for list item 1." + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "List item 2" + detail: "Description for list item 2." + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "list" + button_icon_position: "before" + assertions: + count: + 'div.ecl-content-item-block__title': 0 + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 0 + 'div.ecl-content-item-block__item': 2 + 'div.ecl-content-item-block__item.ecl-col-l-6': 2 + 'div.ecl-content-item-block__item.ecl-col-l-4': 0 + 'div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item': 2 + 'div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item': 0 + 'div.ecl-content-item-block__button': 1 + 'div.ecl-content-item-block__button a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-before[href="http://example.com"]': 1 + equals: + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "List item 1" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "Description for list item 1." + 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__title': "List item 2" + 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__description': "Description for list item 2." + 'a.ecl-link': 'View all' - array: '#type': pattern '#id': list_item_block_three_columns @@ -1434,6 +1538,49 @@ 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__description': "Description for list item 2." 'div.ecl-content-item-block__item:nth-child(3) article.ecl-content-item div.ecl-content-item__title': "List item 3" 'div.ecl-content-item-block__item:nth-child(3) article.ecl-content-item div.ecl-content-item__description': "Description for list item 3." +- array: + '#type': pattern + '#id': list_item_block_three_columns + '#fields': + items: + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "List item 1" + detail: "Description for list item 1." + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "List item 2" + detail: "Description for list item 2." + - '#type': "pattern" + '#id': "list_item" + '#fields': + title: "List item 3" + detail: "Description for list item 3." + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "language" + button_icon_position: "after" + assertions: + count: + 'div.ecl-content-item-block__title': 0 + 'div.ecl-content-item-block__title h2.ecl-u-type-heading-2': 0 + 'div.ecl-content-item-block__item': 3 + 'div.ecl-content-item-block__item.ecl-col-l-6': 0 + 'div.ecl-content-item-block__item.ecl-col-l-4': 3 + 'div.ecl-content-item-block__item.ecl-col-l-6 article.ecl-content-item': 0 + 'div.ecl-content-item-block__item.ecl-col-l-4 article.ecl-content-item': 3 + 'div.ecl-content-item-block__button': 1 + 'div.ecl-content-item-block__button a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-after[href="http://example.com"]': 1 + equals: + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__title': "List item 1" + 'div.ecl-content-item-block__item:nth-child(1) article.ecl-content-item div.ecl-content-item__description': "Description for list item 1." + 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__title': "List item 2" + 'div.ecl-content-item-block__item:nth-child(2) article.ecl-content-item div.ecl-content-item__description': "Description for list item 2." + 'div.ecl-content-item-block__item:nth-child(3) article.ecl-content-item div.ecl-content-item__title': "List item 3" + 'div.ecl-content-item-block__item:nth-child(3) article.ecl-content-item div.ecl-content-item__description': "Description for list item 3." + 'a.ecl-link': 'View all' - array: '#type': pattern '#id': list_item_block_four_columns @@ -1443,12 +1590,17 @@ - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 2' } } - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 3' } } - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 4' } } + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "list" + button_icon_position: "before" assertions: equals: 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(1) a.ecl-link': 'A simple link 1' 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(2) a.ecl-link': 'A simple link 2' 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(3) a.ecl-link': 'A simple link 3' 'div.ecl-content-item-block__item.ecl-col-l-3:nth-child(4) a.ecl-link': 'A simple link 4' + 'a.ecl-link--icon-before': 'View all' - array: '#type': pattern '#id': list_item_block_six_columns @@ -1460,6 +1612,10 @@ - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 4' } } - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 5' } } - { '#type': 'pattern', '#id': 'link', '#fields': { url: '#', text: 'A simple link 6' } } + button_label: "View all" + button_url: "http://example.com" + button_icon_name: "list" + button_icon_position: "before" assertions: equals: 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(1) a.ecl-link': 'A simple link 1' @@ -1468,6 +1624,7 @@ 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(4) a.ecl-link': 'A simple link 4' 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(5) a.ecl-link': 'A simple link 5' 'div.ecl-content-item-block__item.ecl-col-l-2:nth-child(6) a.ecl-link': 'A simple link 6' + 'a.ecl-link--icon-before': 'View all' - array: '#type': pattern '#id': navigation_list From 44338de4255dc5f035cea3ac77d1df778ff5a305 Mon Sep 17 00:00:00 2001 From: Imanol Eguskiza Date: Tue, 9 Nov 2021 16:45:43 +0100 Subject: [PATCH 28/28] EWPP-755: Update list item assertion. --- tests/src/PatternAssertions/ListItemAssert.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/PatternAssertions/ListItemAssert.php b/tests/src/PatternAssertions/ListItemAssert.php index c60f03fdd..726343fc8 100644 --- a/tests/src/PatternAssertions/ListItemAssert.php +++ b/tests/src/PatternAssertions/ListItemAssert.php @@ -278,7 +278,7 @@ protected function assertIcon($expected, Crawler $crawler): void { return; } $icon = $crawler->filter($icon_selector); - self::assertContains($expected, $icon->attr('xlink:href')); + self::assertStringContainsString($expected, $icon->attr('xlink:href')); } /** @@ -302,7 +302,7 @@ protected function assertBadges(?array $expected_badges, string $variant, Crawle continue; } $selector = $base_selector . ' span.ecl-label.ecl-label--' . $badge['variant'] . '.ecl-u-mr-xs'; - self::assertContains($badge['label'], $crawler->filter($selector)->text()); + self::assertStringContainsString($badge['label'], $crawler->filter($selector)->text()); } }