diff --git a/CHANGELOG.md b/CHANGELOG.md index 74a14c065..05d2f4747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,31 @@ # 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)) + ## [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)) diff --git a/README.md b/README.md index bb2285e04..447aa9a32 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 fdc795e08..8028e8bd8 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 diff --git a/composer.json b/composer.json index c284582f2..13cec5bfc 100644 --- a/composer.json +++ b/composer.json @@ -7,11 +7,11 @@ "prefer-stable": true, "require": { "php": ">=7.3", - "drupal/core": "^8.9.14", + "drupal/core": "^8.9.14 || ^9.1", "drupal/smart_trim": "^1.2", "drupal/twig_field_value": "^2.0", "drupal/ui_patterns": "^1.0", - "openeuropa/ecl-twig-loader": "^3.0", + "openeuropa/ecl-twig-loader": "^3.1", "openeuropa/oe_time_caching": "~1.0", "ralouphie/mimey": "^2.1" }, @@ -20,7 +20,7 @@ "consolidation/annotated-command": "^2.8.2", "consolidation/robo": "~1.4", "cweagans/composer-patches": "~1.6.7", - "drupal/core-composer-scaffold": "^8.8", + "drupal/core-composer-scaffold": "^8.9 || ^9.1", "drupal/address": "~1.9", "drupal/composite_reference": "~1.0-alpha1", "drupal/config_devel": "~1.2", @@ -36,34 +36,36 @@ "drupal/inline_entity_form": "~1.0-rc9", "drupal/json_field": "^1.0.0-rc2", "drupal/renderviz": "^1.0@alpha", - "drupal/styleguide": "~1.0-alpha3", + "drupal/styleguide": "~1.0@beta", + "drush/drush": "~10.3", "drupal/typed_link": "^2.0", - "drush/drush": "~9.0", "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/code-review": "~1.6", + "openeuropa/drupal-core-require-dev": "^8.9 || ^9.1", "openeuropa/oe_content": "~2.6", "openeuropa/oe_corporate_blocks": "~4.0", "openeuropa/oe_corporate_countries": "~2.0", "openeuropa/oe_media": "~1.12", "openeuropa/oe_multilingual": "~1.8", "openeuropa/oe_paragraphs": "~1.10", - "openeuropa/oe_search": "~1.0", - "openeuropa/oe_webtools": "~1.10", + "openeuropa/oe_search": "1.x-dev", + "openeuropa/oe_webtools": "~1.12", "openeuropa/oe_contact_forms": "~1.1", "openeuropa/rdf_skos": "~1.0", "openeuropa/task-runner-drupal-project-symlink": "^1.0", - "phpunit/phpunit": "~6.0", - "symfony/dom-crawler": "~3.4" + "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.", - "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.", + "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." ], "conflict": { "openeuropa/oe_corporate_blocks": "<3.0.0", @@ -80,7 +82,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_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_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_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/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); diff --git a/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php b/modules/oe_theme_helper/src/TwigExtension/TwigExtension.php index ec5e241d7..21574fba6 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,17 @@ 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']), + new TwigFilter('create_markup', [$this, 'createMarkup']), ]; } @@ -83,9 +82,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 +545,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 +555,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(); @@ -705,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/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/FunctionalJavascript/InPageNavigationBlockTest.php b/modules/oe_theme_helper/tests/src/FunctionalJavascript/InPageNavigationBlockTest.php index ef16985ed..5f7fb9e55 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->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 705ff2edb..d96b3d9ab 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->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/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php b/modules/oe_theme_helper/tests/src/Kernel/Plugin/Field/FieldFormatter/MediaGalleryFormatterTest.php index a00e2b7c1..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 @@ -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. @@ -218,11 +218,14 @@ 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->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 +237,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 +274,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 +308,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 +319,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( - '/files/styles/medium/public/oembed_thumbnails/LQU9BWkA66xEaKfV_f74OO3Uyu1KMVLOsIi9WQYTjSg.jpg?itok=', + $this->assertStringContainsString( + '/files/styles/medium/public/oembed_thumbnails/' . $expected_thumbnail_name . '?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/Functional/RetinaScaleEffectTest.php b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php similarity index 59% rename from modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php rename to modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php index 2e06ad553..d6b9510c1 100644 --- a/modules/oe_theme_helper/tests/src/Functional/RetinaScaleEffectTest.php +++ b/modules/oe_theme_helper/tests/src/Kernel/RetinaScaleEffectTest.php @@ -2,23 +2,38 @@ declare(strict_types = 1); -namespace Drupal\Tests\oe_theme_helper\Functional; +namespace Drupal\Tests\oe_theme_helper\Kernel; -use Drupal\FunctionalTests\Image\ToolkitTestBase; +use Drupal\KernelTests\KernelTestBase; +use Drupal\Tests\oe_theme_helper\Traits\ToolkitTestTrait; /** * Tests that the Retina Scale effect upscales images appropriately. * * @group image * - * @group batch3 + * @group batch2 */ -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']; + protected static $modules = [ + 'image', + 'image_test', + 'oe_theme_helper', + 'system', + ]; /** * The image effect manager. @@ -30,16 +45,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 +69,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]); + $this->assertEquals(10, $calls['scale'][0][1]); } /** * 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 +85,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]); } /** * 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]); } /** * 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,21 +114,25 @@ 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]); } /** * 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, 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), 'Function returned the expected value.'); + $this->assertTrue($effect->applyEffect($this->image)); } } diff --git a/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Kernel/TwigExtensionTest.php index 7eaabf73a..15fa790e7 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/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); + } + + } +} diff --git a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php index ddd3934df..599aa2883 100644 --- a/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php +++ b/modules/oe_theme_helper/tests/src/Unit/TwigExtensionTest.php @@ -4,12 +4,16 @@ 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; 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 +57,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 +85,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 +217,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 +260,7 @@ public function invalidLanguageCodesProvider(): array { * names as values. */ protected static function getEuropeanUnionLanguageList(): array { - return TwigExtension::getEuropeanUnionLanguageList(); + return EuropeanUnionLanguages::getLanguageList(); } /** @@ -358,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); + } + } 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 1ffcb637c..de7f270c7 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 de06c2969..7ce8811b5 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 b36f26a4c..ef8ea87a3 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 764f5eb73..598c63b70 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 ce08f8d4c..c02abe14e 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 fcc9357a3..b3de35b46 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 a26b02283..e845658cd 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 f6821bc8f..e049b7198 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 14385ad1e..d64e1ac51 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 a63841650..497f860bf 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 8d2aa0dce..3da3f381d 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 4a38a65ee..e97c17710 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 f80e64430..51865238b 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 a14079a20..dae317de6 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 34a2b37ee..b82b8b102 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 d43814482..113dbf3c3 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 829e891c5..1356808b0 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 a3a33f489..a12cac48c 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 2b25b66ba..e629f367a 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 f6beeefd4..fb469ae2f 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 5b9134e26..25e8b462d 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 c4c8294da..09a5b18d7 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 38955e6fe..aabe9137a 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" 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 a5a4d7a49..e8ca51f6b 100644 --- a/oe_theme.theme +++ b/oe_theme.theme @@ -440,13 +440,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; @@ -455,7 +462,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. @@ -490,7 +497,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), @@ -505,7 +512,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', @@ -540,7 +547,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' => [ @@ -562,7 +569,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', @@ -579,7 +586,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..ea773f57f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - + @@ -9,11 +9,11 @@ - - - + + + - + ./modules/**/tests/ ./tests/ 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/EnsurePHPUnitBatchingTestListener.php b/tests/EnsurePHPUnitBatchingTestListener.php deleted file mode 100644 index 17c4cce42..000000000 --- a/tests/EnsurePHPUnitBatchingTestListener.php +++ /dev/null @@ -1,34 +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); - } - } - } - -} 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 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 99% rename from tests/Behat/OeThemeTestContext.php rename to tests/src/Behat/OeThemeTestContext.php index dac195db3..85b5f2ed6 100644 --- a/tests/Behat/OeThemeTestContext.php +++ b/tests/src/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/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/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/Functional/BreadcrumbTest.php b/tests/src/Functional/BreadcrumbTest.php similarity index 89% rename from tests/Functional/BreadcrumbTest.php rename to tests/src/Functional/BreadcrumbTest.php index 0a5ab9f2a..fcdb72899 100644 --- a/tests/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. */ 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 fcae38328..6423e0bde 100755 --- a/tests/Functional/ConfigurationTest.php +++ b/tests/src/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->config('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->config('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->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 1a12474f9..cc18be313 100644 --- a/tests/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'; diff --git a/tests/Functional/ContentCallForTendersRenderTest.php b/tests/src/Functional/ContentCallForTendersRenderTest.php similarity index 100% rename from tests/Functional/ContentCallForTendersRenderTest.php rename to tests/src/Functional/ContentCallForTendersRenderTest.php diff --git a/tests/Functional/ContentConsultationRenderTest.php b/tests/src/Functional/ContentConsultationRenderTest.php similarity index 98% rename from tests/Functional/ContentConsultationRenderTest.php rename to tests/src/Functional/ContentConsultationRenderTest.php index 7ae33f276..185e25452 100644 --- a/tests/Functional/ContentConsultationRenderTest.php +++ b/tests/src/Functional/ContentConsultationRenderTest.php @@ -253,7 +253,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 +546,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 +585,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/src/Functional/ContentEventRenderTest.php similarity index 100% rename from tests/Functional/ContentEventRenderTest.php rename to tests/src/Functional/ContentEventRenderTest.php diff --git a/tests/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php similarity index 98% rename from tests/Functional/ContentNewsRenderTest.php rename to tests/src/Functional/ContentNewsRenderTest.php index 2e58e5848..cdb830345 100644 --- a/tests/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -208,7 +208,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('files/styles/oe_theme_medium_no_crop/public/placeholder_news_featured_media.png', $image->getAttribute('src')); + $this->assertStringContainsString('files/styles/oe_theme_medium_no_crop/public/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/src/Functional/ContentOrganisationRenderTest.php similarity index 96% rename from tests/Functional/ContentOrganisationRenderTest.php rename to tests/src/Functional/ContentOrganisationRenderTest.php index c2b0f2f57..e7b873d54 100644 --- a/tests/Functional/ContentOrganisationRenderTest.php +++ b/tests/src/Functional/ContentOrganisationRenderTest.php @@ -115,7 +115,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 +154,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 +270,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/src/Functional/ContentPersonRenderTest.php similarity index 97% rename from tests/Functional/ContentPersonRenderTest.php rename to tests/src/Functional/ContentPersonRenderTest.php index 8b164a01c..28d38c0da 100644 --- a/tests/Functional/ContentPersonRenderTest.php +++ b/tests/src/Functional/ContentPersonRenderTest.php @@ -85,7 +85,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 +109,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 +310,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/src/Functional/ContentProjectRenderTest.php similarity index 97% rename from tests/Functional/ContentProjectRenderTest.php rename to tests/src/Functional/ContentProjectRenderTest.php index 289d344fc..7a3555837 100644 --- a/tests/Functional/ContentProjectRenderTest.php +++ b/tests/src/Functional/ContentProjectRenderTest.php @@ -147,7 +147,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 +232,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 +356,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 +379,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/src/Functional/ContentPublicationRenderTest.php similarity index 98% rename from tests/Functional/ContentPublicationRenderTest.php rename to tests/src/Functional/ContentPublicationRenderTest.php index c1de782d3..aa88f1423 100644 --- a/tests/Functional/ContentPublicationRenderTest.php +++ b/tests/src/Functional/ContentPublicationRenderTest.php @@ -286,8 +286,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/src/Functional/ContentRenderTestBase.php similarity index 95% rename from tests/Functional/ContentRenderTestBase.php rename to tests/src/Functional/ContentRenderTestBase.php index 88ef0cd27..85f327486 100644 --- a/tests/Functional/ContentRenderTestBase.php +++ b/tests/src/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. @@ -380,7 +385,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/src/Functional/CorporateFooterRenderTest.php similarity index 99% rename from tests/Functional/CorporateFooterRenderTest.php rename to tests/src/Functional/CorporateFooterRenderTest.php index ccc11a223..3dcb565e7 100644 --- a/tests/Functional/CorporateFooterRenderTest.php +++ b/tests/src/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->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 @@ -818,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 94% rename from tests/Functional/ParagraphsTest.php rename to tests/src/Functional/ParagraphsTest.php index 4080eff74..ae203cecf 100644 --- a/tests/Functional/ParagraphsTest.php +++ b/tests/src/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/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 96% rename from tests/FunctionalJavascript/JavascriptBehavioursTest.php rename to tests/src/FunctionalJavascript/JavascriptBehavioursTest.php index 37b812d57..90a9d7973 100644 --- a/tests/FunctionalJavascript/JavascriptBehavioursTest.php +++ b/tests/src/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->config('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/src/Kernel/AbstractKernelTestBase.php similarity index 79% rename from tests/Kernel/AbstractKernelTestBase.php rename to tests/src/Kernel/AbstractKernelTestBase.php index c72bd7d72..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; /** @@ -35,7 +36,7 @@ abstract class AbstractKernelTestBase extends KernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('user'); @@ -49,9 +50,19 @@ protected function setUp() { ]); $this->container->get('theme_installer')->install(['oe_theme']); - $this->container->get('theme_handler')->setDefault('oe_theme'); + $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 90% rename from tests/Kernel/BlockTest.php rename to tests/src/Kernel/BlockTest.php index 876ca07f4..c7f5709ff 100644 --- a/tests/Kernel/BlockTest.php +++ b/tests/src/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->config('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/src/Kernel/BreadcrumbTest.php similarity index 97% rename from tests/Kernel/BreadcrumbTest.php rename to tests/src/Kernel/BreadcrumbTest.php index 506dc67ad..461366544 100644 --- a/tests/Kernel/BreadcrumbTest.php +++ b/tests/src/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->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 99% rename from tests/Kernel/ConsultationRenderTest.php rename to tests/src/Kernel/ConsultationRenderTest.php index c2fa95b05..aa520f777 100644 --- a/tests/Kernel/ConsultationRenderTest.php +++ b/tests/src/Kernel/ConsultationRenderTest.php @@ -32,6 +32,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/Kernel/ContactFormRenderTest.php b/tests/src/Kernel/ContactFormRenderTest.php similarity index 94% rename from tests/Kernel/ContactFormRenderTest.php rename to tests/src/Kernel/ContactFormRenderTest.php index 89097cc9a..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('theme_handler')->setDefault('oe_theme'); + $this->config('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/src/Kernel/ContactRenderTest.php similarity index 98% rename from tests/Kernel/ContactRenderTest.php rename to tests/src/Kernel/ContactRenderTest.php index ff1aa1010..48d2949eb 100644 --- a/tests/Kernel/ContactRenderTest.php +++ b/tests/src/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/src/Kernel/ContentLanguageSwitcherTest.php similarity index 97% rename from tests/Kernel/ContentLanguageSwitcherTest.php rename to tests/src/Kernel/ContentLanguageSwitcherTest.php index b1aaeaf9e..de8f812bb 100644 --- a/tests/Kernel/ContentLanguageSwitcherTest.php +++ b/tests/src/Kernel/ContentLanguageSwitcherTest.php @@ -29,7 +29,7 @@ class ContentLanguageSwitcherTest extends MultilingualAbstractKernelTestBase { /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->installEntitySchema('node'); @@ -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 99% rename from tests/Kernel/ContentRenderTestBase.php rename to tests/src/Kernel/ContentRenderTestBase.php index aa64d5ae3..502034741 100644 --- a/tests/Kernel/ContentRenderTestBase.php +++ b/tests/src/Kernel/ContentRenderTestBase.php @@ -85,7 +85,7 @@ abstract class ContentRenderTestBase extends MultilingualAbstractKernelTestBase /** * {@inheritdoc} */ - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->setUpSparql(); 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 99% rename from tests/Kernel/LanguageSwitcherTest.php rename to tests/src/Kernel/LanguageSwitcherTest.php index 61b33c6a0..dbbfb0f0a 100644 --- a/tests/Kernel/LanguageSwitcherTest.php +++ b/tests/src/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/src/Kernel/LegacyContentRenderTest.php similarity index 89% rename from tests/Kernel/LegacyContentRenderTest.php rename to tests/src/Kernel/LegacyContentRenderTest.php index 22f678a80..e1967cc14 100644 --- a/tests/Kernel/LegacyContentRenderTest.php +++ b/tests/src/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('div.ecl-u-border-bottom.ecl-u-border-color-grey-15.ecl-u-pt-m.ecl-u-pb-m a'); $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/src/Kernel/MainMenuTest.php similarity index 98% rename from tests/Kernel/MainMenuTest.php rename to tests/src/Kernel/MainMenuTest.php index 557122d46..e8268842b 100644 --- a/tests/Kernel/MainMenuTest.php +++ b/tests/src/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/src/Kernel/MediaRenderTest.php similarity index 99% rename from tests/Kernel/MediaRenderTest.php rename to tests/src/Kernel/MediaRenderTest.php index 053cf380b..ac2dd13fa 100644 --- a/tests/Kernel/MediaRenderTest.php +++ b/tests/src/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/src/Kernel/MenuLocalTasksTest.php similarity index 98% rename from tests/Kernel/MenuLocalTasksTest.php rename to tests/src/Kernel/MenuLocalTasksTest.php index 5b80baace..930d0b991 100644 --- a/tests/Kernel/MenuLocalTasksTest.php +++ b/tests/src/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/src/Kernel/MultilingualAbstractKernelTestBase.php similarity index 98% rename from tests/Kernel/MultilingualAbstractKernelTestBase.php rename to tests/src/Kernel/MultilingualAbstractKernelTestBase.php index 165cef8c5..9196bac26 100644 --- a/tests/Kernel/MultilingualAbstractKernelTestBase.php +++ b/tests/src/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/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 84% rename from tests/Kernel/PagerTest.php rename to tests/src/Kernel/PagerTest.php index 7c097e104..06adc4f8a 100644 --- a/tests/Kernel/PagerTest.php +++ b/tests/src/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/src/Kernel/Paragraphs/ContactParagraphTest.php similarity index 97% rename from tests/Kernel/Paragraphs/ContactParagraphTest.php rename to tests/src/Kernel/Paragraphs/ContactParagraphTest.php index e1561d053..07e1517dc 100644 --- a/tests/Kernel/Paragraphs/ContactParagraphTest.php +++ b/tests/src/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/src/Kernel/Paragraphs/ContentRowTest.php similarity index 83% rename from tests/Kernel/Paragraphs/ContentRowTest.php rename to tests/src/Kernel/Paragraphs/ContentRowTest.php index 2dde8cfb4..849df1259 100644 --- a/tests/Kernel/Paragraphs/ContentRowTest.php +++ b/tests/src/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/src/Kernel/Paragraphs/MediaParagraphsTest.php similarity index 90% rename from tests/Kernel/Paragraphs/MediaParagraphsTest.php rename to tests/src/Kernel/Paragraphs/MediaParagraphsTest.php index 0bfaa63de..5062b393d 100644 --- a/tests/Kernel/Paragraphs/MediaParagraphsTest.php +++ b/tests/src/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'); @@ -250,7 +250,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([ @@ -451,14 +451,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. @@ -466,7 +466,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') ); @@ -502,14 +502,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. @@ -521,14 +521,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. @@ -542,14 +542,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'); @@ -561,14 +561,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'); @@ -580,14 +580,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'); @@ -599,14 +599,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. @@ -619,14 +619,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. @@ -647,7 +647,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. @@ -669,7 +669,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'); @@ -688,7 +688,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'); @@ -708,7 +708,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'); @@ -728,7 +728,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'); @@ -748,7 +748,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'); @@ -767,7 +767,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'); @@ -788,7 +788,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. @@ -820,7 +820,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') ); @@ -861,9 +861,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(); @@ -873,22 +873,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'); @@ -896,9 +896,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', [ @@ -914,9 +914,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/src/Kernel/Paragraphs/ParagraphsTest.php similarity index 99% rename from tests/Kernel/Paragraphs/ParagraphsTest.php rename to tests/src/Kernel/Paragraphs/ParagraphsTest.php index 5098cec11..47ce5e18a 100644 --- a/tests/Kernel/Paragraphs/ParagraphsTest.php +++ b/tests/src/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/src/Kernel/Paragraphs/ParagraphsTestBase.php similarity index 98% rename from tests/Kernel/Paragraphs/ParagraphsTestBase.php rename to tests/src/Kernel/Paragraphs/ParagraphsTestBase.php index 34c44dae4..7ed34efc8 100644 --- a/tests/Kernel/Paragraphs/ParagraphsTestBase.php +++ b/tests/src/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/src/Kernel/Paragraphs/SocialMediaFollowTest.php similarity index 86% rename from tests/Kernel/Paragraphs/SocialMediaFollowTest.php rename to tests/src/Kernel/Paragraphs/SocialMediaFollowTest.php index c4b301718..066531bde 100644 --- a/tests/Kernel/Paragraphs/SocialMediaFollowTest.php +++ b/tests/src/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/src/Kernel/Paragraphs/TimelineParagraphTest.php similarity index 99% rename from tests/Kernel/Paragraphs/TimelineParagraphTest.php rename to tests/src/Kernel/Paragraphs/TimelineParagraphTest.php index ff957d007..ae3ddaf35 100644 --- a/tests/Kernel/Paragraphs/TimelineParagraphTest.php +++ b/tests/src/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/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 97% rename from tests/Kernel/Patterns/FilePatternRenderingTest.php rename to tests/src/Kernel/Patterns/FilePatternRenderingTest.php index 28a7dbd57..1277bbcf7 100644 --- a/tests/Kernel/Patterns/FilePatternRenderingTest.php +++ b/tests/src/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/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 99% rename from tests/Kernel/PersonRenderTest.php rename to tests/src/Kernel/PersonRenderTest.php index 7bea5bd7d..0a8807c0a 100644 --- a/tests/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', diff --git a/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php b/tests/src/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php similarity index 80% rename from tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php rename to tests/src/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php index 26b168406..9403e10c0 100644 --- a/tests/Kernel/Plugin/Condition/CurrentComponentLibraryConditionTest.php +++ b/tests/src/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/src/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php similarity index 81% rename from tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php rename to tests/src/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php index c800a6505..2dc7cd540 100644 --- a/tests/Kernel/Plugin/Condition/CurrentEclBrandingConditionTest.php +++ b/tests/src/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/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 98% rename from tests/Kernel/RenderingTest.php rename to tests/src/Kernel/RenderingTest.php index 1ff01f05f..3e724aa13 100644 --- a/tests/Kernel/RenderingTest.php +++ b/tests/src/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/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 99% rename from tests/Kernel/StatusMessagesTest.php rename to tests/src/Kernel/StatusMessagesTest.php index 7ebb0954c..eda4f4655 100644 --- a/tests/Kernel/StatusMessagesTest.php +++ b/tests/src/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/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 95% rename from tests/Kernel/TimelineTest.php rename to tests/src/Kernel/TimelineTest.php index 548ea9db0..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('theme_handler')->setDefault('oe_theme'); + $this->config('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/src/Kernel/ValueObject/DateTimeRangeTest.php similarity index 98% rename from tests/Kernel/ValueObject/DateTimeRangeTest.php rename to tests/src/Kernel/ValueObject/DateTimeRangeTest.php index ce7705a59..ff1e37d60 100644 --- a/tests/Kernel/ValueObject/DateTimeRangeTest.php +++ b/tests/src/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/src/Kernel/ValueObject/DateTimeTest.php similarity index 98% rename from tests/Kernel/ValueObject/DateTimeTest.php rename to tests/src/Kernel/ValueObject/DateTimeTest.php index f1bd1038d..42943701b 100644 --- a/tests/Kernel/ValueObject/DateTimeTest.php +++ b/tests/src/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/src/Kernel/ValueObject/DateTimeTestBase.php similarity index 95% rename from tests/Kernel/ValueObject/DateTimeTestBase.php rename to tests/src/Kernel/ValueObject/DateTimeTestBase.php index b154307b0..8db40d322 100644 --- a/tests/Kernel/ValueObject/DateTimeTestBase.php +++ b/tests/src/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'); + $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 85% rename from tests/Kernel/ValueObject/ImageTest.php rename to tests/src/Kernel/ValueObject/ImageTest.php index a2cc9bf8f..d6286839a 100644 --- a/tests/Kernel/ValueObject/ImageTest.php +++ b/tests/src/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'); @@ -55,7 +55,7 @@ protected function setUp() { ])->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'); } /** @@ -89,10 +89,10 @@ 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->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); } diff --git a/tests/Kernel/Webtools/SocialShareTest.php b/tests/src/Kernel/Webtools/SocialShareTest.php similarity index 93% rename from tests/Kernel/Webtools/SocialShareTest.php rename to tests/src/Kernel/Webtools/SocialShareTest.php index 6cecbc1d9..3b6a92970 100644 --- a/tests/Kernel/Webtools/SocialShareTest.php +++ b/tests/src/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/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 92% rename from tests/Kernel/fixtures/rendering.yml rename to tests/src/Kernel/fixtures/rendering.yml index 37ec7b57c..e14f316aa 100644 --- a/tests/Kernel/fixtures/rendering.yml +++ b/tests/src/Kernel/fixtures/rendering.yml @@ -1300,6 +1300,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" @@ -1330,6 +1332,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." @@ -1388,6 +1391,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 @@ -1419,6 +1487,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 @@ -1457,6 +1561,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 @@ -1466,12 +1613,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 @@ -1483,6 +1635,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' @@ -1491,6 +1647,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 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 1a7236b1d..f024991e9 100644 --- a/tests/PatternAssertions/BasePatternAssert.php +++ b/tests/src/PatternAssertions/BasePatternAssert.php @@ -195,7 +195,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/src/PatternAssertions/FeaturedItemAssert.php similarity index 95% rename from tests/PatternAssertions/FeaturedItemAssert.php rename to tests/src/PatternAssertions/FeaturedItemAssert.php index 5b50d145e..1d47b7fa5 100644 --- a/tests/PatternAssertions/FeaturedItemAssert.php +++ b/tests/src/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/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 95% rename from tests/PatternAssertions/FileAssert.php rename to tests/src/PatternAssertions/FileAssert.php index 6b8e1242e..cb5cc5057 100644 --- a/tests/PatternAssertions/FileAssert.php +++ b/tests/src/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/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 93% rename from tests/PatternAssertions/IconsTextAssert.php rename to tests/src/PatternAssertions/IconsTextAssert.php index 6cce85159..ec7544729 100644 --- a/tests/PatternAssertions/IconsTextAssert.php +++ b/tests/src/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/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 96% rename from tests/PatternAssertions/ListItemAssert.php rename to tests/src/PatternAssertions/ListItemAssert.php index f4c5cff89..726343fc8 100644 --- a/tests/PatternAssertions/ListItemAssert.php +++ b/tests/src/PatternAssertions/ListItemAssert.php @@ -197,7 +197,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')); } /** @@ -213,7 +213,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')); } /** @@ -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()); } } 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 93% rename from tests/PatternAssertions/SocialMediaLinksAssert.php rename to tests/src/PatternAssertions/SocialMediaLinksAssert.php index 7b52d9f83..ca9147b0d 100644 --- a/tests/PatternAssertions/SocialMediaLinksAssert.php +++ b/tests/src/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/PatternAssertions/TextFeaturedMediaAssert.php b/tests/src/PatternAssertions/TextFeaturedMediaAssert.php similarity index 97% rename from tests/PatternAssertions/TextFeaturedMediaAssert.php rename to tests/src/PatternAssertions/TextFeaturedMediaAssert.php index b7543e676..4ed7cee20 100644 --- a/tests/PatternAssertions/TextFeaturedMediaAssert.php +++ b/tests/src/PatternAssertions/TextFeaturedMediaAssert.php @@ -98,7 +98,7 @@ protected function assertLink(array $expected_link, Crawler $crawler): void { self::assertEquals($expected_link['label'], $label_element->text()); $svg = $link_element->filter('svg.ecl-icon.ecl-icon--s.ecl-icon--primary.ecl-link__icon use'); - self::assertContains('icons.svg#' . $expected_link['icon'], $svg->attr('xlink:href')); + self::assertStringContainsString('icons.svg#' . $expected_link['icon'], $svg->attr('xlink:href')); } /** diff --git a/tests/Traits/RenderTrait.php b/tests/src/Traits/RenderTrait.php similarity index 97% rename from tests/Traits/RenderTrait.php rename to tests/src/Traits/RenderTrait.php index 617a5d14b..5b7cb8b2e 100644 --- a/tests/Traits/RenderTrait.php +++ b/tests/src/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/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 89% rename from tests/Unit/ValueObject/ImageValueObjectTest.php rename to tests/src/Unit/ValueObject/ImageValueObjectTest.php index c6d07c300..01ce4a9ff 100644 --- a/tests/Unit/ValueObject/ImageValueObjectTest.php +++ b/tests/src/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); @@ -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(). * @@ -161,7 +139,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/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