diff --git a/composer.lock b/composer.lock index 6134bb7eada485cbc298bd0b64ac1a904a20b8a5..5d579bffaf3548aa90e57577a4a91c1c97fe946e 100644 --- a/composer.lock +++ b/composer.lock @@ -4721,42 +4721,45 @@ }, { "name": "drupal/metatag", - "version": "2.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://git.drupalcode.org/project/metatag.git", - "reference": "2.0.0" + "reference": "2.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/metatag-2.0.0.zip", - "reference": "2.0.0", - "shasum": "2966c854d982b7069b1c0111519427990ebbad40" + "url": "https://ftp.drupal.org/files/projects/metatag-2.0.2.zip", + "reference": "2.0.2", + "shasum": "748013c50a0ed5e10359413bb3481392a0bf0d3f" }, "require": { - "drupal/core": "^9.4 || ^10", + "drupal/core": "^9.4 || ^10 || ^11", "drupal/token": "^1.0", "php": ">=8.0" }, "require-dev": { - "drupal/devel": "^4.0 || ^5.0", - "drupal/hal": "^9 || ^1 || ^2", + "drupal/hal": "^1 || ^2 || ^9", "drupal/metatag_dc": "*", "drupal/metatag_open_graph": "*", "drupal/page_manager": "^4.0", "drupal/redirect": "^1.0", - "drupal/webprofiler": "^9 || ^10", + "ergebnis/composer-normalize": "*", "mpyw/phpunit-patch-serializable-comparison": "*" }, "type": "drupal-module", "extra": { "drupal": { - "version": "2.0.0", - "datestamp": "1692368265", + "version": "2.0.2", + "datestamp": "1722869772", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" } + }, + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" } }, "notification-url": "https://packages.drupal.org/8/downloads", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 94915c5f628a7a348d34e8513158150af24bbff1..4a2c3e3daba0cceb88938aa0267997ffdce79b53 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -4967,43 +4967,46 @@ }, { "name": "drupal/metatag", - "version": "2.0.0", - "version_normalized": "2.0.0.0", + "version": "2.0.2", + "version_normalized": "2.0.2.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/metatag.git", - "reference": "2.0.0" + "reference": "2.0.2" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/metatag-2.0.0.zip", - "reference": "2.0.0", - "shasum": "2966c854d982b7069b1c0111519427990ebbad40" + "url": "https://ftp.drupal.org/files/projects/metatag-2.0.2.zip", + "reference": "2.0.2", + "shasum": "748013c50a0ed5e10359413bb3481392a0bf0d3f" }, "require": { - "drupal/core": "^9.4 || ^10", + "drupal/core": "^9.4 || ^10 || ^11", "drupal/token": "^1.0", "php": ">=8.0" }, "require-dev": { - "drupal/devel": "^4.0 || ^5.0", - "drupal/hal": "^9 || ^1 || ^2", + "drupal/hal": "^1 || ^2 || ^9", "drupal/metatag_dc": "*", "drupal/metatag_open_graph": "*", "drupal/page_manager": "^4.0", "drupal/redirect": "^1.0", - "drupal/webprofiler": "^9 || ^10", + "ergebnis/composer-normalize": "*", "mpyw/phpunit-patch-serializable-comparison": "*" }, "type": "drupal-module", "extra": { "drupal": { - "version": "2.0.0", - "datestamp": "1692368265", + "version": "2.0.2", + "datestamp": "1722869772", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" } + }, + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" } }, "installation-source": "dist", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 13f2c64c0eff1074f0d40e2e31920a04877d998b..b3271eb369e4a030b35f861b7e8830f56a5ea708 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'osu-asc-webservices/d8-upstream', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '95bc84d8582ade2a962640f92cd1496d54d37c56', + 'reference' => 'd85ef4c34240e822ad3c5a4a0b68dfdd51dec002', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -881,9 +881,9 @@ 'dev_requirement' => false, ), 'drupal/metatag' => array( - 'pretty_version' => '2.0.0', - 'version' => '2.0.0.0', - 'reference' => '2.0.0', + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => '2.0.2', 'type' => 'drupal-module', 'install_path' => __DIR__ . '/../../web/modules/metatag', 'aliases' => array(), @@ -1555,7 +1555,7 @@ 'osu-asc-webservices/d8-upstream' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '95bc84d8582ade2a962640f92cd1496d54d37c56', + 'reference' => 'd85ef4c34240e822ad3c5a4a0b68dfdd51dec002', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/web/modules/metatag/.cspell-project-words.txt b/web/modules/metatag/.cspell-project-words.txt new file mode 100644 index 0000000000000000000000000000000000000000..20137da00015d88ecf03da02564542bac3f8a01c --- /dev/null +++ b/web/modules/metatag/.cspell-project-words.txt @@ -0,0 +1,95 @@ +Acquia +alexa +applinks +Barfoo +bla'bleblu +blable +bleblu +breen +CDTF +checkall +cilefen +cleartype +ctools +Cxense +DCMI +DCMITYPE +dcterms +deeplinking +donottrack +dont +eengi +encodeded +ergebnis +ERRORPAGE +esource +Geertruyen +getentity +getroute +Globant +googleplay +handheldfriendly +Inheritence +inkscape +Juampy +Kandelaars +Kenna +LAUJ +linkcheckerlink +Maxlenth +Mediacurrent +metatagd +Metatagtrimmer +mobileoptimized +msapplication +Mscw +msvalidate +mtid +navbutton +neede +Nikhilesh +noarchive +nodeword +nodewords +nodewordsd +nohover +noimageindex +noodp +nopagereadaloud +Nopin +nopin +nosearch +nositelinkssearchbox +Novillo +noydir +Olivas +opengraph +precomposed +Rakesh +Requena +Rowlands +safeweb +scrollheight +scrollheightvalue +shorturl +sitelinks +siwecos +siwecostoken +starturl +straem +Tagtrimmer +tilecolor +tileimage +tnid +tobe +trid +trimlengths +trimmable +unaliased +Uzcw +waldomero +webform +xdefault +YFMEKD +Yoast +Yxuz diff --git a/web/modules/metatag/.eslintrc b/web/modules/metatag/.eslintrc index 9faa37508e533c82089e0485dd9e9907370a309d..c59a275e23199f2da7bfc38002886f3afd2c0e56 100644 --- a/web/modules/metatag/.eslintrc +++ b/web/modules/metatag/.eslintrc @@ -57,7 +57,7 @@ rules: no-case-declarations: 2 no-div-regex: 2 no-else-return: 0 - no-empty-label: 2 + no-empty-label: 0 no-empty-pattern: 2 no-eq-null: 2 no-eval: 2 diff --git a/web/modules/metatag/.gitlab-ci.yml b/web/modules/metatag/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..372f1f85be31e3307fb4b51d4bd9ce012b2c15f0 --- /dev/null +++ b/web/modules/metatag/.gitlab-ci.yml @@ -0,0 +1,121 @@ +################ +# DrupalCI GitLabCI template +# +# Gitlab-ci.yml to replicate DrupalCI testing for Contrib +# +# With thanks to: +# * The GitLab Acceleration Initiative participants +# * DrupalSpoons +################ + +################ +# Guidelines +# +# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained. +# +# However, you can modify this template if you have additional needs for your project. +################ + +################ +# Includes +# +# Additional configuration can be provided through includes. +# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include. +# +# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml +# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values +################ + +include: + ################ + # DrupalCI includes: + # As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically. + # View these include files at https://git.drupalcode.org/project/gitlab_templates/ + ################ + - project: $_GITLAB_TEMPLATES_REPO + # "ref" value can be: + # - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib. + # - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates. + # - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features). + # - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates. + # If you change the default value of ref, you should set the _CURL_TEMPLATES_REF variable in the variables section to be the same as set here. + ref: $_GITLAB_TEMPLATES_REF + file: + - "/includes/include.drupalci.main.yml" + # For Drupal 7, remove the above line and uncomment the below. + # - "/includes/include.drupalci.main-d7.yml" + - "/includes/include.drupalci.variables.yml" + - "/includes/include.drupalci.workflows.yml" +# +################ +# Pipeline configuration variables +# +# These are the variables provided to the Run Pipeline form that a user may want to override. +# +# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml +################ + +variables: + # Run tests in parallel. + _PHPUNIT_CONCURRENT: 1 + # Run tests against the previous and next core minor releases, to help make + # sure small changes don't break anything too quickly. + OPT_IN_TEST_NEXT_MINOR: 1 + OPT_IN_TEST_PREVIOUS_MINOR: 1 + +# Don't allow failures from coding standards tests. +cspell: + allow_failure: false +phpcs: + allow_failure: false +# @todo Fix all phpstan issues. +# phstan: +# allow_failure: false +stylelint: + allow_failure: false + +################################################################################### +# +# * +# /( +# ((((, +# /((((((( +# ((((((((((* +# ,((((((((((((((( +# ,((((((((((((((((((( +# ((((((((((((((((((((((((* +# *((((((((((((((((((((((((((((( +# ((((((((((((((((((((((((((((((((((* +# *(((((((((((((((((( .(((((((((((((((((( +# ((((((((((((((((((. /(((((((((((((((((* +# /((((((((((((((((( .(((((((((((((((((, +# ,(((((((((((((((((( (((((((((((((((((( +# .(((((((((((((((((((( .((((((((((((((((( +# ((((((((((((((((((((((( ((((((((((((((((/ +# (((((((((((((((((((((((((((/ ,(((((((((((((((* +# .((((((((((((((/ /(((((((((((((. ,((((((((((((((( +# *(((((((((((((( ,(((((((((((((/ *((((((((((((((. +# ((((((((((((((, /(((((((((((((. ((((((((((((((, +# (((((((((((((/ ,(((((((((((((* ,(((((((((((((, +# *((((((((((((( .((((((((((((((( ,((((((((((((( +# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/ +# ((((((((((((( *(((((((((((((((((((((((* *(((((((((((( +# ((((((((((((( ,(((((((((((((..((((((((((((( *(((((((((((( +# ((((((((((((, /((((((((((((* /((((((((((((/ (((((((((((( +# ((((((((((((( /((((((((((((/ (((((((((((((* (((((((((((( +# (((((((((((((/ /(((((((((((( ,((((((((((((, *(((((((((((( +# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/ +# *((((((((((((((((((((((((((, /((((((((((((((((((((((((( +# ((((((((((((((((((((((((( ((((((((((((((((((((((((, +# .(((((((((((((((((((((((/ ,((((((((((((((((((((((( +# ((((((((((((((((((((((/ ,(((((((((((((((((((((/ +# *((((((((((((((((((((( (((((((((((((((((((((, +# ,(((((((((((((((((((((, ((((((((((((((((((((/ +# ,(((((((((((((((((((((* /(((((((((((((((((((( +# ((((((((((((((((((((((, ,/((((((((((((((((((((, +# ,((((((((((((((((((((((((((((((((((((((((((((((((((( +# .((((((((((((((((((((((((((((((((((((((((((((( +# .((((((((((((((((((((((((((((((((((((,. +# .,(((((((((((((((((((((((((. +# +################################################################################ diff --git a/web/modules/metatag/CHANGELOG.txt b/web/modules/metatag/CHANGELOG.txt index 1814c30644aef8257013e13160d3ea8ad524d2ef..9a167e7128c9a658748867c07eef2d89a9eb505e 100644 --- a/web/modules/metatag/CHANGELOG.txt +++ b/web/modules/metatag/CHANGELOG.txt @@ -1,3 +1,35 @@ +Metatag 2.0.2, 2024-08-05 +------------------------- +#3465991 by podarok, DamienMcKenna: Allow installation on Drupal 11 via + composer.json. + + +Metatag 2.0.1, 2024-08-05 +------------------------- +#3370486 by DamienMcKenna, arti_parmar: Use second argument on all unserialize() + calls. +#3386862 by DamienMcKenna: Additional entity types to ignore. +#3390226 by DamienMcKenna: Normalize the composer.json file using + ergebnis/composer-normalize. +#3408825 by DamienMcKenna: Remove Devel, WebProfiler tests. +#3413633 by Nikolay Shapovalov, DamienMcKenna, Mingsong: Fix tests for, + compatibility with Drupal 10.2. +#3404463 by pilot3, DamienMcKenna, Nikolay Shapovalov, naveenvalecha: Add Gitlab + CI test file. +#3421648 by morgannc, DamienMcKenna: Fixed some coding standards issues. +#3423881 by DamienMcKenna: Merge NodeTranslation into + MetatagNodeTranslationTest. +#3433055 by DamienMcKenna: Fixed test filenames. +#3447058 by DamienMcKenna: Update info files for Drupal 11. +#3462134 by ankitv18, DamienMcKenna: Fix phpcs and cspell issues. +#3454762 by johnjw59@gmail.com, DamienMcKenna: Page Manager meta tags added + twice. +#3460593 by DamienMcKenna, porchlight, acbramley: Update MetatagFieldBuilder + ::build for compatibility with Diff v2. +#3423428 by DamienMcKenna, naveenvalecha: cspell, stylelint coding standards + fixes. + + Metatag 2.0.0, 2023-06-27 ------------------------- #3364475 by DamienMcKenna: Update scripts to convert JSON data on revision diff --git a/web/modules/metatag/README.md b/web/modules/metatag/README.md index 6993eac4e1292557c57aef83b4d21c7a9ad89e51..5c1f750256ff1e49ef5a19a7e57c634abf291b59 100644 --- a/web/modules/metatag/README.md +++ b/web/modules/metatag/README.md @@ -361,6 +361,16 @@ the page check, to see if the html.html.twig instead contains this: To fix this, simply change that line back to `{{ page }}` and it should work. +## Contributing + +The `composer.json` file should be kept normalized using +`ergebnis/composer-normalize`: + +* `composer require --dev ergebnis/composer-normalize` +* `composer normalize modules/contrib/metatag/composer.json` + + + ## Maintainers / credits / contact Currently maintained by [Damien diff --git a/web/modules/metatag/composer.json b/web/modules/metatag/composer.json index 3041a90c395089fb2ee63496bf432e6f3a90d639..5c807d8acd9d99a04c20ce707731cf443b20f9e8 100644 --- a/web/modules/metatag/composer.json +++ b/web/modules/metatag/composer.json @@ -1,13 +1,12 @@ { "name": "drupal/metatag", "description": "Manage meta tags for all entities.", - "type": "drupal-module", "license": "GPL-2.0-or-later", + "type": "drupal-module", "keywords": [ "Drupal", "seo" ], - "homepage": "https://www.drupal.org/project/metatag", "authors": [ { "name": "See contributors", @@ -15,23 +14,29 @@ "role": "Developer" } ], - "minimum-stability": "dev", + "homepage": "https://www.drupal.org/project/metatag", "support": { "issues": "https://www.drupal.org/project/issues/metatag", "source": "https://git.drupalcode.org/project/metatag", "docs": "https://www.drupal.org/docs/8/modules/metatag" }, "require": { - "drupal/core": "^9.4 || ^10", - "drupal/token": "^1.0", - "php": ">=8.0" + "php": ">=8.0", + "drupal/core": "^9.4 || ^10 || ^11", + "drupal/token": "^1.0" }, "require-dev": { - "drupal/devel": "^4.0 || ^5.0", - "drupal/hal": "^9 || ^1 || ^2", - "drupal/redirect": "^1.0", + "drupal/hal": "^1 || ^2 || ^9", "drupal/page_manager": "^4.0", - "drupal/webprofiler": "^9 || ^10", + "drupal/redirect": "^1.0", + "ergebnis/composer-normalize": "*", "mpyw/phpunit-patch-serializable-comparison": "*" + }, + "minimum-stability": "dev", + "extra": { + "composer-normalize": { + "indent-size": 2, + "indent-style": "space" + } } } diff --git a/web/modules/metatag/css/firehose_widget.css b/web/modules/metatag/css/firehose_widget.css index c601bce58636f4e968efbff0ca0dbe7bb68defb6..1c28a28a255fc51ae5eefee387e87f2d0d6bc32e 100644 --- a/web/modules/metatag/css/firehose_widget.css +++ b/web/modules/metatag/css/firehose_widget.css @@ -4,6 +4,6 @@ */ .metatags { - max-height: 500px; overflow-y: overlay; + max-height: 500px; } diff --git a/web/modules/metatag/metatag.info.yml b/web/modules/metatag/metatag.info.yml index 7f26ca02ba1dc63f58232087adb839702de8b90d..1a6395b8f6567441a040e69b1b1dc5a2cfbd1db0 100644 --- a/web/modules/metatag/metatag.info.yml +++ b/web/modules/metatag/metatag.info.yml @@ -1,17 +1,15 @@ name: Metatag type: module description: Manage meta tags for all entities. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO php: 8.0 configure: entity.metatag_defaults.collection dependencies: - drupal:field - token:token -test_dependencies: - - devel:devel -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag.module b/web/modules/metatag/metatag.module index c9a2fcead1caa47837e308b5f522fe3879b584ee..ba90c386ba28ebf3fa70ef20b548b7d647b965be 100644 --- a/web/modules/metatag/metatag.module +++ b/web/modules/metatag/metatag.module @@ -5,6 +5,7 @@ * Contains metatag.module. */ +use Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\ProductDisplay; use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Serialization\Json; @@ -16,6 +17,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Drupal\migrate\Plugin\migrate\destination\EntityContentBase; use Drupal\migrate\Plugin\MigrateSourceInterface; @@ -28,8 +30,6 @@ use Drupal\taxonomy\TermInterface; use Drupal\user\Plugin\migrate\source\d6\User as User6; use Drupal\user\Plugin\migrate\source\d7\User as User7; -use Drupal\Core\StringTranslation\TranslatableMarkup; -use Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\ProductDisplay; /** * Implements hook_help(). @@ -95,6 +95,10 @@ function metatag_form_field_config_edit_form_alter(&$form, FormStateInterface $f $form['default_value']['#access'] = FALSE; $form['default_value']['#disabled'] = TRUE; + // Hide the cardinality field. + $form['cardinality_container']['#access'] = FALSE; + $form['cardinality_container']['#disabled'] = TRUE; + // Step through the default value structure and erase any '#default_value' // items that are found. foreach ($form['default_value']['widget'][0] as &$outer) { @@ -950,6 +954,21 @@ function _metatag_is_migration_plugin_supported(array $definition) { 'shortcut_set_users', 'url_alias', 'user_data', + // Various contrib modules. + 'entity:commerce_order', + 'entity:commerce_payment', + 'entity:commerce_payment_method', + 'entity:commerce_promotion', + 'entity:commerce_promotion_coupon', + 'entity:commerce_shipment', + 'entity:commerce_shipping_method', + 'entity:commerce_stock_location', + 'entity:commerce_store', + 'entity:linkcheckerlink', + 'entity:path_alias', + 'entity:redirect', + 'entity:salesforce_mapped_object', + 'entity:webform_submission', ]; if (in_array($definition['destination']['plugin'], $destinations_to_ignore)) { return FALSE; diff --git a/web/modules/metatag/metatag.post_update.php b/web/modules/metatag/metatag.post_update.php index b34eee7a98d8f716dc44f9c9e01992752d57d3f3..78bc0f4546cca9ba4addb99ad8adfeb3823d837e 100644 --- a/web/modules/metatag/metatag.post_update.php +++ b/web/modules/metatag/metatag.post_update.php @@ -130,7 +130,6 @@ function metatag_post_update_convert_author_config(&$sandbox) { * The author meta tag was moved into the main module: entity data. */ function metatag_post_update_convert_author_data(&$sandbox) { - $entity_type_manager = \Drupal::entityTypeManager(); $database = \Drupal::database(); // This whole top section only needs to be done the first time. @@ -195,7 +194,7 @@ function metatag_post_update_convert_author_data(&$sandbox) { // Strip any empty tags or ones matching the field's defaults and leave // only the overridden tags in $new_tags. - $tags = unserialize($record->$field_value_field); + $tags = unserialize($record->$field_value_field, ['allowed_classes' => FALSE]); if (isset($tags['google_plus_author'])) { $tags['author'] = $tags['google_plus_author']; $tags_string = serialize($tags); @@ -247,7 +246,6 @@ function metatag_post_update_convert_author_data(&$sandbox) { * Remove 'noydir', 'noodp' ROBOTS options from meta tag entity fields. */ function metatag_post_update_remove_robots_noydir_noodp(&$sandbox) { - $entity_type_manager = \Drupal::entityTypeManager(); $database = \Drupal::database(); // This whole top section only needs to be done the first time. @@ -377,7 +375,6 @@ function metatag_post_update_remove_robots_noydir_noodp(&$sandbox) { * Convert all fields to use JSON storage. */ function metatag_post_update_v2_01_change_fields_to_json(&$sandbox) { - $entity_type_manager = \Drupal::entityTypeManager(); $database = \Drupal::database(); // This whole top section only needs to be done the first time. @@ -444,23 +441,23 @@ function metatag_post_update_v2_01_change_fields_to_json(&$sandbox) { // @todo Remove tags matching the defaults and leave overridden values. if (substr($record->$field_value_field, 0, 2) === 'a:') { $tags = @unserialize($record->$field_value_field, ['allowed_classes' => FALSE]); + + if (is_array($tags)) { + $tags_string = Json::encode($tags); + $database->update($field_table) + ->fields([ + $field_value_field => $tags_string, + ]) + ->condition('entity_id', $record->entity_id) + ->condition('revision_id', $record->revision_id) + ->condition('langcode', $record->langcode) + ->execute(); + } + $counter++; } else { throw new UpdateException("It seems like there was a problem with the data. The update script should probably be improved to better handle these scenarios."); } - - if (is_array($tags)) { - $tags_string = Json::encode($tags); - $database->update($field_table) - ->fields([ - $field_value_field => $tags_string, - ]) - ->condition('entity_id', $record->entity_id) - ->condition('revision_id', $record->revision_id) - ->condition('langcode', $record->langcode) - ->execute(); - } - $counter++; } if (empty($counter)) { $sandbox['current_field']++; @@ -493,7 +490,6 @@ function metatag_post_update_v2_01_change_fields_to_json(&$sandbox) { * Remove meta tags entity values that were removed in v2. */ function metatag_post_update_v2_02_remove_entity_values(array &$sandbox) { - $entity_type_manager = \Drupal::entityTypeManager(); $database = \Drupal::database(); $metatags_to_remove = [ diff --git a/web/modules/metatag/metatag_app_links/metatag_app_links.info.yml b/web/modules/metatag/metatag_app_links/metatag_app_links.info.yml index ba4676022ed50a7691bfd8cd5b764b4136f8d1ec..0902e143e3ff6d67929142abd0290f22f2fda70d 100644 --- a/web/modules/metatag/metatag_app_links/metatag_app_links.info.yml +++ b/web/modules/metatag/metatag_app_links/metatag_app_links.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: App Links' type: module description: Provides support for applinks.org meta tags. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_dc/metatag_dc.info.yml b/web/modules/metatag/metatag_dc/metatag_dc.info.yml index ee799e9f3e0bed03c2063d1e5326b6c2e3c601f0..4ed2e3b4904b32e4b1d9783321faaa3eec5d3979 100644 --- a/web/modules/metatag/metatag_dc/metatag_dc.info.yml +++ b/web/modules/metatag/metatag_dc/metatag_dc.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Dublin Core' type: module description: Provides the fifteen <a href="https://dublincore.org/documents/dces/">Dublin Core Metadata Element Set 1.1</a> meta tags from the <a href="https://dublincore.org/">Dublin Core Metadata Institute</a>. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_dc_advanced/metatag_dc_advanced.info.yml b/web/modules/metatag/metatag_dc_advanced/metatag_dc_advanced.info.yml index b3f66994bab079e1b630ee894cfc4d275048e319..5606be4d29e0ebaaee8f6b0551be31dc703a144e 100644 --- a/web/modules/metatag/metatag_dc_advanced/metatag_dc_advanced.info.yml +++ b/web/modules/metatag/metatag_dc_advanced/metatag_dc_advanced.info.yml @@ -1,13 +1,13 @@ name: 'Metatag: Dublin Core Advanced' type: module description: 'Provides forty additional meta tags from the <a href="https://dublincore.org/">Dublin Core Metadata Institute</a>.' -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag - metatag:metatag_dc -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_extended_perms/README.txt b/web/modules/metatag/metatag_extended_perms/README.txt index a742dc2836df99310775ba827e834adfb4853310..2e7e902c7613fbc54b0b20c1c899789292c8d918 100644 --- a/web/modules/metatag/metatag_extended_perms/README.txt +++ b/web/modules/metatag/metatag_extended_perms/README.txt @@ -49,7 +49,11 @@ function mysite_update_9001() { // Look for permissions that started with the old permission string. if (strpos($perm, 'access metatag tag') !== FALSE) { // Grand the new permission. - $role->grantPermission(str_replace('access metatag tag', 'access metatag', $perm)); + $role->grantPermission( + str_replace( + 'access metatag tag', 'access metatag', $perm + ) + ); // Track that the role's permissions changed. $changed = TRUE; diff --git a/web/modules/metatag/metatag_extended_perms/metatag_extended_perms.info.yml b/web/modules/metatag/metatag_extended_perms/metatag_extended_perms.info.yml index d32f53ab777d3c1071867ee2b1c52051d592cfa4..3228cf4f06af7d3fd1f2b160573a6a0e9f261746 100644 --- a/web/modules/metatag/metatag_extended_perms/metatag_extended_perms.info.yml +++ b/web/modules/metatag/metatag_extended_perms/metatag_extended_perms.info.yml @@ -1,12 +1,12 @@ name: Metatag Extended Permissions type: module description: "Adds individual permissions for each meta tag, allowing for fine-grained access to the meta tags. Note: this may lead to performance issues on the permissions admin page, please see the included README.txt file for details." -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_extended_perms/tests/src/Functional/PermissionsTest.php b/web/modules/metatag/metatag_extended_perms/tests/src/Functional/PermissionsTest.php index 569e3eb2cf71fff662ec24cc80b38975779f0b53..a304d1d17f1e744451a03c498d58e077cf2f295e 100644 --- a/web/modules/metatag/metatag_extended_perms/tests/src/Functional/PermissionsTest.php +++ b/web/modules/metatag/metatag_extended_perms/tests/src/Functional/PermissionsTest.php @@ -2,9 +2,10 @@ namespace Drupal\Tests\metatag_extended_perms\Functional; +use Drupal\node\Entity\NodeType; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; use Drupal\Tests\metatag\Functional\MetatagHelperTrait; -use Drupal\node\Entity\NodeType; /** * Verify the new permissions are added. @@ -14,6 +15,7 @@ class PermissionsTest extends BrowserTestBase { // Contains helper methods. + use FieldUiTestTrait; use MetatagHelperTrait; /** @@ -198,15 +200,7 @@ protected function createContentType(array $values = []): NodeType { $this->drupalGet('node/add/page'); // Add a metatag field to the entity type test_entity. - $this->drupalGet('admin/structure/types/manage/page/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, 'Save and continue'); - $this->submitForm([], 'Save field settings'); + $this->fieldUIAddNewField('admin/structure/types/manage/page', 'metatag', 'Metatag', 'metatag'); // Clear all settings. $this->container->get('entity_field.manager')->clearCachedFieldDefinitions(); diff --git a/web/modules/metatag/metatag_facebook/metatag_facebook.info.yml b/web/modules/metatag/metatag_facebook/metatag_facebook.info.yml index 75c721de73982759208f01ae0e1c89d4f07f152c..f436eee7b00ce79ddd23e593b393317007dc5118 100644 --- a/web/modules/metatag/metatag_facebook/metatag_facebook.info.yml +++ b/web/modules/metatag/metatag_facebook/metatag_facebook.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Facebook' type: module description: A set of meta tags specially for controlling advanced functionality with Facebook. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_favicons/metatag_favicons.info.yml b/web/modules/metatag/metatag_favicons/metatag_favicons.info.yml index f0891bfe0bde73635e5a84ff1f36f6e6c7d517ca..a2eca8d7dbe13802a774ec6a9dc0cb38189bf921 100644 --- a/web/modules/metatag/metatag_favicons/metatag_favicons.info.yml +++ b/web/modules/metatag/metatag_favicons/metatag_favicons.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Favicons' type: module description: Provides support for many different favicons. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php b/web/modules/metatag/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php index b9d6c0d11f09ed2b773432e03568af58ee37bf62..2facd048b93533d4fcd2c74e10b6681dc6acd257 100644 --- a/web/modules/metatag/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php +++ b/web/modules/metatag/metatag_favicons/src/Plugin/metatag/Tag/MaskIcon.php @@ -2,8 +2,8 @@ namespace Drupal\metatag_favicons\Plugin\metatag\Tag; -use Drupal\metatag\Plugin\metatag\Tag\LinkRelBase; use Drupal\Component\Utility\Random; +use Drupal\metatag\Plugin\metatag\Tag\LinkRelBase; /** * The Favicons "mask-icon" meta tag. diff --git a/web/modules/metatag/metatag_favicons/tests/src/Functional/TagsTest.php b/web/modules/metatag/metatag_favicons/tests/src/Functional/TagsTest.php index 7a9a06b1c0c178c63f461f883b8cb5f8f8ea246d..3767a09800bde5181a6fb9416b86b5c5dba8a449 100644 --- a/web/modules/metatag/metatag_favicons/tests/src/Functional/TagsTest.php +++ b/web/modules/metatag/metatag_favicons/tests/src/Functional/TagsTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\metatag_favicons\Functional; use Drupal\Component\Serialization\Json; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; use Drupal\Tests\metatag\Functional\TagsTestBase; /** @@ -12,6 +13,8 @@ */ class TagsTest extends TagsTestBase { + use FieldUiTestTrait; + /** * {@inheritdoc} */ @@ -25,15 +28,7 @@ public function testMaskIconLegacy() { // Add a metatag field to the entity type test_entity. $this->createContentType(['type' => 'page']); - $this->drupalGet('admin/structure/types/manage/page/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, 'Save and continue'); - $this->submitForm([], 'Save field settings'); + $this->fieldUIAddNewField('admin/structure/types/manage/page', 'metatag', 'Metatag', 'metatag'); // Create a demo node of this content type so it can be tested. $this->drupalGet('node/add/page'); diff --git a/web/modules/metatag/metatag_google_cse/metatag_google_cse.info.yml b/web/modules/metatag/metatag_google_cse/metatag_google_cse.info.yml index f62400f8ed796290b0cf063e0efb22bb6d62c8df..637ebe347376043f008b61f6b02ce609ecf18c9c 100644 --- a/web/modules/metatag/metatag_google_cse/metatag_google_cse.info.yml +++ b/web/modules/metatag/metatag_google_cse/metatag_google_cse.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Google Custom Search Engine (CSE)' type: module description: Provides support for meta tags used for Google Custom Search Engine. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_google_plus/metatag_google_plus.info.yml b/web/modules/metatag/metatag_google_plus/metatag_google_plus.info.yml index a1d923422557ca762d4bcf4cbb24ba01f59249cf..eb6fcb681e39e98722c7badce4688de74aa1bbe7 100644 --- a/web/modules/metatag/metatag_google_plus/metatag_google_plus.info.yml +++ b/web/modules/metatag/metatag_google_plus/metatag_google_plus.info.yml @@ -1,13 +1,13 @@ name: 'Metatag: Google Plus' type: module description: Deprecated module, do not use. Will be removed in 3.0.0. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO hidden: true dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_hreflang/metatag_hreflang.info.yml b/web/modules/metatag/metatag_hreflang/metatag_hreflang.info.yml index 57c8e83cf6fadab2a66cbf8c6e1472cc3b27f710..cecf97713b36386338a22cd4d1330e15fc2bd083 100644 --- a/web/modules/metatag/metatag_hreflang/metatag_hreflang.info.yml +++ b/web/modules/metatag/metatag_hreflang/metatag_hreflang.info.yml @@ -1,12 +1,12 @@ name: "Metatag: Hreflang" type: module description: Provides support for the hreflang meta tag with some extra logic to simplify it. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_hreflang/src/Plugin/metatag/Tag/HreflangPerLanguage.php b/web/modules/metatag/metatag_hreflang/src/Plugin/metatag/Tag/HreflangPerLanguage.php index 8c0477d6f0b216e6c4842e00f053d03fcecef1b8..954df7b6c1a719030fab61a413a5d828dad9c900 100644 --- a/web/modules/metatag/metatag_hreflang/src/Plugin/metatag/Tag/HreflangPerLanguage.php +++ b/web/modules/metatag/metatag_hreflang/src/Plugin/metatag/Tag/HreflangPerLanguage.php @@ -2,8 +2,6 @@ namespace Drupal\metatag_hreflang\Plugin\metatag\Tag; -use Drupal\Component\Utility\Random; - /** * A new hreflang tag will be made available for each language. * @@ -42,14 +40,25 @@ public function getTestFormXpath(): array { * {@inheritdoc} */ public function getTestFormData(): array { - $random = new Random(); + return []; - return [ - // @todo Submitting this value results in the following error: - // Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for metatag.metatag_defaults.global with the following errors: metatag.metatag_defaults.global:tags.hreflang_per_language:hreflang_en missing schema in Drupal\Core\Config\Development\ConfigSchemaChecker->onConfigSave() (line 94 of core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php). - - // 'hreflang_per_language:hreflang_en' => 'https://www.example.com/' . $random->word(6) . '.html', - ]; + // @todo Submitting this value results in the following error: + // Drupal\Core\Config\Schema\SchemaIncompleteException: + // Schema errors for metatag.metatag_defaults.global + // with the following errors: + // metatag.metatag_defaults.global:tags.hreflang_per_language:hreflang_en + // missing schema in + // Drupal\Core\Config\Development\ConfigSchemaChecker->onConfigSave() + // Line 94 of + // core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php + // @code + // $random = new Random(); + // $hreflang = 'https://www.example.com/' . $random->word(6) . '.html'; + // + // return [ + // 'hreflang_per_language:hreflang_en' => $hreflang, + // ]; + // @endcode } /** diff --git a/web/modules/metatag/metatag_mobile/metatag_mobile.info.yml b/web/modules/metatag/metatag_mobile/metatag_mobile.info.yml index 4a25264f22b3afd82f86eff75556d524d517e00f..1254f6fba857563b986d16d27b6a5b93bc838dd9 100644 --- a/web/modules/metatag/metatag_mobile/metatag_mobile.info.yml +++ b/web/modules/metatag/metatag_mobile/metatag_mobile.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Mobile & UI Adjustments' type: module description: Provides support for meta tags used to control the mobile browser experience. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_mobile/metatag_mobile.module b/web/modules/metatag/metatag_mobile/metatag_mobile.module index 1ac1f72797626410a6fc39b9a32d49b5f2ed229a..0ce517c65a409ab33af375190fc33fc62188446f 100644 --- a/web/modules/metatag/metatag_mobile/metatag_mobile.module +++ b/web/modules/metatag/metatag_mobile/metatag_mobile.module @@ -53,11 +53,7 @@ function metatag_mobile_page_attachments_alter(array &$attachments) { // found so it can be picked up as the dupe; this is important for the // "viewport" meta tag where both core and Metatag use the same name. if (in_array($item[1], $meta_tags) && !isset($found[$core_tag])) { - foreach ($meta_tags as $meta_tag) { - if (!isset($found[$core_tag])) { - $found[$core_tag] = $key; - } - } + $found[$core_tag] = $key; } elseif ($item[1] == $core_tag && isset($found[$core_tag])) { // @todo This ought to work, but doesn't? diff --git a/web/modules/metatag/metatag_mobile/tests/src/Functional/TestCoreTagRemoval.php b/web/modules/metatag/metatag_mobile/tests/src/Functional/TestCoreTagRemoval.php index 6c90ae2f252c23873a121d497f417f003d35960c..8eb137cce57a2b73f9a1442635b82c04320c2586 100644 --- a/web/modules/metatag/metatag_mobile/tests/src/Functional/TestCoreTagRemoval.php +++ b/web/modules/metatag/metatag_mobile/tests/src/Functional/TestCoreTagRemoval.php @@ -3,8 +3,8 @@ namespace Drupal\Tests\metatag_mobile\Functional; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; use Drupal\Tests\metatag\Functional\MetatagHelperTrait; -use Drupal\user\Entity\User; /** * Verify that the configured defaults load as intended. @@ -14,6 +14,7 @@ class TestCoreTagRemoval extends BrowserTestBase { // Contains helper methods. + use FieldUiTestTrait; use MetatagHelperTrait; /** @@ -30,6 +31,8 @@ class TestCoreTagRemoval extends BrowserTestBase { /** * Use the full install profile, with the full theme. + * + * @var string */ protected $profile = 'standard'; @@ -43,23 +46,13 @@ protected function setUp(): void { $this->loginUser1(); // Add the Metatag field to the content type. - $this->drupalGet('admin/structure/types/manage/page/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, 'Save and continue'); - $this->submitForm([], 'Save field settings'); - $this->assertSession()->statusCodeEquals(200); + $this->fieldUIAddNewField('admin/structure/types/manage/page', 'metatag', 'Metatag', 'metatag'); } - /** * Verify that core's duplicate meta tags are removed. */ - public function testCoreTagRemoval() { + public function testRemovalCoreTag() { // Create a node that does not override core's meta tags. $this->drupalGet('node/add/page'); $this->assertSession()->statusCodeEquals(200); diff --git a/web/modules/metatag/metatag_open_graph/metatag_open_graph.info.yml b/web/modules/metatag/metatag_open_graph/metatag_open_graph.info.yml index 09727058997fb3c9999a9c3a6278dbe5c91c0d9b..889f0015384a6b339f1436d2c3280ad5f757cb46 100644 --- a/web/modules/metatag/metatag_open_graph/metatag_open_graph.info.yml +++ b/web/modules/metatag/metatag_open_graph/metatag_open_graph.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Open Graph' type: module description: Provides support for Open Graph Protocol meta tags. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_open_graph_products/metatag_open_graph_products.info.yml b/web/modules/metatag/metatag_open_graph_products/metatag_open_graph_products.info.yml index 98b70574bc9b7c53868c877d5b579a02cc34ccbe..13a8ab9cf9b29d3a5201628970db4c7b10d2a922 100644 --- a/web/modules/metatag/metatag_open_graph_products/metatag_open_graph_products.info.yml +++ b/web/modules/metatag/metatag_open_graph_products/metatag_open_graph_products.info.yml @@ -1,13 +1,13 @@ name: 'Metatag: Open Graph Products' type: module description: Provides additional Open Graph Protocol meta tags for describing products. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag - metatag:metatag_open_graph -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_page_manager/metatag_page_manager.info.yml b/web/modules/metatag/metatag_page_manager/metatag_page_manager.info.yml index 921b515941365a63034184124e3847df5acafeeb..d4b402aa581b422397d79efd41ffa89e8dde0f5b 100644 --- a/web/modules/metatag/metatag_page_manager/metatag_page_manager.info.yml +++ b/web/modules/metatag/metatag_page_manager/metatag_page_manager.info.yml @@ -1,13 +1,13 @@ name: 'Metatag: Page Manager' type: module description: Provides metatag support for Page Manager variants. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - page_manager:page_manager - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_page_manager/metatag_page_manager.module b/web/modules/metatag/metatag_page_manager/metatag_page_manager.module index 68e0a5ba85e66ead3d8aa893aeeb831246340900..b886467958ec7eea2845ebbd0ab51f2d6a858d6a 100644 --- a/web/modules/metatag/metatag_page_manager/metatag_page_manager.module +++ b/web/modules/metatag/metatag_page_manager/metatag_page_manager.module @@ -5,10 +5,10 @@ * Contains metatag_page_manager.module. */ -use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\page_manager\Entity\PageVariant; +use Drupal\Core\Routing\RouteMatchInterface; use Drupal\metatag\Entity\MetatagDefaults; +use Drupal\page_manager\Entity\PageVariant; /** * Implements hook_form_FORM_ID_alter(). @@ -18,46 +18,6 @@ function metatag_page_manager_form_metatag_defaults_add_form_alter(&$form, FormS $form['id']['#options'] = array_merge($form['id']['#options'], $variants_options); } -/** - * Implements hook_page_attachments(). - */ -function metatag_page_manager_page_attachments(array &$attachments) { - // Fetch entity from request. - $entity = \Drupal::request()->attributes->get('_entity'); - if ($entity) { - - $key = $entity->getEntityType()->id() . '__' . $entity->id(); - // Get default metatags. - $metatag_defaults = metatag_get_default_tags(); - // Load page variant metatags. - $metatag_variant = MetatagDefaults::load($key); - if ($metatag_variant) { - // Overwrite the metatag defaults with the tags of the page variant. - $metatag_defaults = array_merge($metatag_defaults, $metatag_variant->get('tags')); - - // Set the metatag in the static metatag attachments parameter so the - // metatag module wouldn't overwrite them. - $metatag_attachments = &drupal_static('metatag_attachments'); - - $metatag_manager = \Drupal::service('metatag.manager'); - $metatag_attachments = $metatag_manager->generateElements($metatag_defaults, $entity); - - // If any Metatag items were found, append them. - if (!empty($metatag_attachments['#attached']['html_head'])) { - if (empty($attachments['#attached'])) { - $attachments['#attached'] = []; - } - if (empty($attachments['#attached']['html_head'])) { - $attachments['#attached']['html_head'] = []; - } - foreach ($metatag_attachments['#attached']['html_head'] as $item) { - $attachments['#attached']['html_head'][] = $item; - } - } - } - } -} - /** * Returns all available page variants. * diff --git a/web/modules/metatag/metatag_pinterest/metatag_pinterest.info.yml b/web/modules/metatag/metatag_pinterest/metatag_pinterest.info.yml index 02adbedf259622e444538e42867c8973689feddb..c219515e7ea642ca159e700d5a532b24528de9b6 100644 --- a/web/modules/metatag/metatag_pinterest/metatag_pinterest.info.yml +++ b/web/modules/metatag/metatag_pinterest/metatag_pinterest.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Pinterest' type: module description: Provides support for Pinterest's custom meta tags. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_routes/metatag_routes.info.yml b/web/modules/metatag/metatag_routes/metatag_routes.info.yml index db0debc85ae65e85c7ff2d61c8aa7b4cf08956c3..532dfe5244137e6d32fb349dd661c51a057a6f2e 100644 --- a/web/modules/metatag/metatag_routes/metatag_routes.info.yml +++ b/web/modules/metatag/metatag_routes/metatag_routes.info.yml @@ -1,12 +1,12 @@ name: 'Metatag Custom Routes (Paths)' type: module description: Allows assigning meta tags to be used on custom routes, equivalent to custom paths. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_routes/src/Form/MetatagCustomCreateForm.php b/web/modules/metatag/metatag_routes/src/Form/MetatagCustomCreateForm.php index abec71fa86660f26ec0f3e64dc1fa1eec84db869..301f30ba22b3d872d1971e65f39717c67e92a658 100644 --- a/web/modules/metatag/metatag_routes/src/Form/MetatagCustomCreateForm.php +++ b/web/modules/metatag/metatag_routes/src/Form/MetatagCustomCreateForm.php @@ -2,13 +2,13 @@ namespace Drupal\metatag_routes\Form; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Core\Routing\RouteProvider; use Drupal\Core\Path\PathValidator; use Drupal\Core\Routing\AdminContext; +use Drupal\Core\Routing\RouteProvider; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Form for creating custom definitions. @@ -52,7 +52,7 @@ public function __construct( EntityTypeManagerInterface $entity_type_manager, RouteProvider $route_provider, PathValidator $path_validator, - AdminContext $admin_context + AdminContext $admin_context, ) { $this->entityTypeManager = $entity_type_manager; $this->routeProvider = $route_provider; diff --git a/web/modules/metatag/metatag_twitter_cards/metatag_twitter_cards.info.yml b/web/modules/metatag/metatag_twitter_cards/metatag_twitter_cards.info.yml index 3f3e070f541a963fead14a937319ab6c0f88fb75..efbfb7883322f1cdc9d066e4270f796061540277 100644 --- a/web/modules/metatag/metatag_twitter_cards/metatag_twitter_cards.info.yml +++ b/web/modules/metatag/metatag_twitter_cards/metatag_twitter_cards.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Twitter Cards' type: module description: Provides support for Twitter's Card meta tags. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_twitter_cards/src/Plugin/metatag/Tag/TwitterCardsType.php b/web/modules/metatag/metatag_twitter_cards/src/Plugin/metatag/Tag/TwitterCardsType.php index ba899ded5ce03cd743de25bdec4faccd6d7803fe..f8a6b6ef7d471541343f2b7bf6cec36f96a05945 100644 --- a/web/modules/metatag/metatag_twitter_cards/src/Plugin/metatag/Tag/TwitterCardsType.php +++ b/web/modules/metatag/metatag_twitter_cards/src/Plugin/metatag/Tag/TwitterCardsType.php @@ -2,8 +2,8 @@ namespace Drupal\metatag_twitter_cards\Plugin\metatag\Tag; -use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase; /** * The Twitter Cards Type-tag. diff --git a/web/modules/metatag/metatag_verification/metatag_verification.info.yml b/web/modules/metatag/metatag_verification/metatag_verification.info.yml index 0fab5ee9790a82a539dfd3162aaa5e7760ee07ea..e79857b61a606814c7534e7637690f7aa3945a95 100644 --- a/web/modules/metatag/metatag_verification/metatag_verification.info.yml +++ b/web/modules/metatag/metatag_verification/metatag_verification.info.yml @@ -1,12 +1,12 @@ name: 'Metatag: Verification' type: module description: Verifies ownership of a site for search engines and other services. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_views/metatag_views.info.yml b/web/modules/metatag/metatag_views/metatag_views.info.yml index 25335acd6dc903184b67b33ab7de863035b20ee8..585f63363ceede4e8bf45f2f66f50f134e497a56 100644 --- a/web/modules/metatag/metatag_views/metatag_views.info.yml +++ b/web/modules/metatag/metatag_views/metatag_views.info.yml @@ -1,13 +1,13 @@ name: 'Metatag: Views' type: module description: Provides views integration for metatags. -core_version_requirement: '^9.4 || ^10' +core_version_requirement: '^9.4 || ^10 || ^11' package: SEO dependencies: - metatag:metatag - drupal:views -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/metatag_views/src/Controller/MetatagViewsTranslationController.php b/web/modules/metatag/metatag_views/src/Controller/MetatagViewsTranslationController.php index 9de54ba8ef1f108e09fc6f29249fa043c9935264..5d047f22d7dbce0c6e94a613ba68a701e968076e 100644 --- a/web/modules/metatag/metatag_views/src/Controller/MetatagViewsTranslationController.php +++ b/web/modules/metatag/metatag_views/src/Controller/MetatagViewsTranslationController.php @@ -2,6 +2,7 @@ namespace Drupal\metatag_views\Controller; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Language\LanguageManagerInterface; @@ -9,7 +10,6 @@ use Drupal\metatag\MetatagManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Drupal\Core\Config\ConfigFactoryInterface; /** * Translate Views meta tags. diff --git a/web/modules/metatag/metatag_views/src/Form/MetatagViewsTranslationForm.php b/web/modules/metatag/metatag_views/src/Form/MetatagViewsTranslationForm.php index 89be8defb545fbe014da1feed4a03139e2b4830a..f9907f930d2fcdc91951e6368374a5624d59eace 100644 --- a/web/modules/metatag/metatag_views/src/Form/MetatagViewsTranslationForm.php +++ b/web/modules/metatag/metatag_views/src/Form/MetatagViewsTranslationForm.php @@ -5,13 +5,13 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\metatag\MetatagManagerInterface; use Drupal\metatag\MetatagTagPluginManager; use Drupal\metatag\MetatagToken; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\language\ConfigurableLanguageManagerInterface; use Drupal\metatag_views\MetatagViewsValuesCleanerTrait; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a form for translating meta tags for views. diff --git a/web/modules/metatag/metatag_views/src/MetatagViewsCacheWrapper.php b/web/modules/metatag/metatag_views/src/MetatagViewsCacheWrapper.php index f58317834e0f5806e5e4e0a0908c5b7695bd18ea..f1c11c8f2f8b9e8169a9e0928d89e26adce51c48 100644 --- a/web/modules/metatag/metatag_views/src/MetatagViewsCacheWrapper.php +++ b/web/modules/metatag/metatag_views/src/MetatagViewsCacheWrapper.php @@ -41,6 +41,25 @@ public function __construct(CachePluginBase $plugin) { $this->plugin = $plugin; } + /** + * Create a new object. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container object. + * @param array $configuration + * The configuration passed in. + * @param string $plugin_id + * The ID the new plugin instance. + * @param string $plugin_definition + * The configuration used on this plugin instance. + * + * @return \Drupal\metatag_views\MetatagViewsCacheWrapper + * An instance of this class. + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + return CachePluginBase::create($container, $configuration, $plugin_id, $plugin_definition); + } + /** * {@inheritdoc} */ @@ -71,7 +90,7 @@ public function cacheGet($type) { switch ($type) { case self::RESULTS: $cutoff = $this->plugin->cacheExpire($type); - // Values to set: $view->result, $view->total_rows, $view->execute_time, + // Values to set: $view->result, $view->total_rows, // $view->current_page and pass row tokens to metatag display extender. if ($cache = \Drupal::cache($this->plugin->resultsBin)->get($this->plugin->generateResultsKey())) { if (!$cutoff || $cache->created > $cutoff) { @@ -80,10 +99,10 @@ public function cacheGet($type) { // Load entities for each result. $view->query->loadEntities($view->result); $view->total_rows = $cache->data['total_rows']; - $view->setCurrentPage($cache->data['current_page'], TRUE); - $view->execute_time = 0; + $view->setCurrentPage($cache->data['current_page']); $extenders = $view->getDisplay()->getExtenders(); if (isset($extenders['metatag_display_extender'])) { + /** @var \Drupal\metatag_views\Plugin\views\display_extender\MetatagDisplayExtender $extenders['metatag_display_extender'] */ $extenders['metatag_display_extender']->setFirstRowTokens($cache->data['first_row_tokens']); } return TRUE; @@ -173,13 +192,6 @@ public function getRowId(ResultRow $row) { return $this->plugin->getRowId($row); } - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - CachePluginBase::create($container, $configuration, $plugin_id, $plugin_definition); - } - /** * {@inheritdoc} */ @@ -219,7 +231,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { * {@inheritdoc} */ public static function trustedCallbacks() { - CachePluginBase::trustedCallbacks(); + return CachePluginBase::trustedCallbacks(); } /** @@ -296,14 +308,14 @@ public function globalTokenForm(&$form, FormStateInterface $form_state) { * {@inheritdoc} */ public static function preRenderAddFieldsetMarkup(array $form) { - CachePluginBase::preRenderAddFieldsetMarkup($form); + return CachePluginBase::preRenderAddFieldsetMarkup($form); } /** * {@inheritdoc} */ public static function preRenderFlattenData($form) { - CachePluginBase::preRenderFlattenData($form); + return CachePluginBase::preRenderFlattenData($form); } /** @@ -324,7 +336,7 @@ public function getProvider() { * {@inheritdoc} */ public static function queryLanguageSubstitutions() { - CachePluginBase::queryLanguageSubstitutions(); + return CachePluginBase::queryLanguageSubstitutions(); } /** @@ -380,7 +392,7 @@ public function setMessenger(MessengerInterface $messenger) { * {@inheritdoc} */ public function messenger() { - $this->plugin->messenger(); + return $this->plugin->messenger(); } /** diff --git a/web/modules/metatag/metatag_views/src/Plugin/views/display_extender/MetatagDisplayExtender.php b/web/modules/metatag/metatag_views/src/Plugin/views/display_extender/MetatagDisplayExtender.php index 3bbcac853200698124de8dff0b68f6cc98ba8a11..cf5b7815ea397492276a3a32ee8c7f8ca862ac2c 100644 --- a/web/modules/metatag/metatag_views/src/Plugin/views/display_extender/MetatagDisplayExtender.php +++ b/web/modules/metatag/metatag_views/src/Plugin/views/display_extender/MetatagDisplayExtender.php @@ -3,12 +3,12 @@ namespace Drupal\metatag_views\Plugin\views\display_extender; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase; use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\ViewExecutable; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Metatag display extender plugin. diff --git a/web/modules/metatag/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php b/web/modules/metatag/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php index 6226677e6c374f32cad3487d54a5e291be072f83..bd842cffc45e4348dea0a8fdca9952fc0566e3f9 100644 --- a/web/modules/metatag/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php +++ b/web/modules/metatag/metatag_views/tests/src/Functional/MetatagViewsBasicsTest.php @@ -66,9 +66,6 @@ public function testViewsUi() { $this->drupalGet('<front>'); $this->assertSession()->statusCodeEquals(200); - // With nothing else configured the front page just has a login form. - $this->assertSession()->pageTextContains('Enter your Drupal username.'); - // Log in as user 1. $this->loginUser1(); diff --git a/web/modules/metatag/phpstan.neon b/web/modules/metatag/phpstan.neon new file mode 100644 index 0000000000000000000000000000000000000000..20815509dfca2d5f2e7f3033477df75fcac35f62 --- /dev/null +++ b/web/modules/metatag/phpstan.neon @@ -0,0 +1,11 @@ +# Configuration file for PHPStan static code checking, see https://phpstan.org. +includes: + - phar://phpstan.phar/conf/bleedingEdge.neon + +parameters: + level: 2 + paths: + - . + ignoreErrors: + # new static() is a best practice in Drupal, so we cannot fix that. + - "#^Unsafe usage of new static#" diff --git a/web/modules/metatag/src/Controller/MetatagController.php b/web/modules/metatag/src/Controller/MetatagController.php index b3be15679472235267475afcbbb0f1c54b6fdbf7..9e8a53514c8b58bd42546c1d6c34e3a9e486cdc3 100644 --- a/web/modules/metatag/src/Controller/MetatagController.php +++ b/web/modules/metatag/src/Controller/MetatagController.php @@ -4,8 +4,8 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\metatag\MetatagTagPluginManager; use Drupal\metatag\MetatagGroupPluginManager; +use Drupal\metatag\MetatagTagPluginManager; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/web/modules/metatag/src/Form/MetatagDefaultsForm.php b/web/modules/metatag/src/Form/MetatagDefaultsForm.php index 421839d13a4b9b19dc44c24bc7e686de6b41dab2..1806d80cdfe9939a7de27a9e580b954e2ad20cb0 100644 --- a/web/modules/metatag/src/Form/MetatagDefaultsForm.php +++ b/web/modules/metatag/src/Form/MetatagDefaultsForm.php @@ -24,6 +24,13 @@ */ class MetatagDefaultsForm extends EntityForm { + /** + * The Metatag defaults object being reverted. + * + * @var \Drupal\metatag\Entity\MetatagDefaults + */ + protected $entity; + /** * The entity type bundle info service. * @@ -353,8 +360,29 @@ public static function getSupportedEntityTypes(): array { 'contact_message', // Menu items. 'menu_link_content', + // Path aliases. + 'path_alias', // Shortcut items. 'shortcut', + // From contributed modules: + // Various Commerce entities. + 'commerce_order', + 'commerce_payment', + 'commerce_payment_method', + 'commerce_promotion', + 'commerce_promotion_coupon', + 'commerce_shipment', + 'commerce_shipping_method', + 'commerce_stock_location', + 'commerce_store', + // LinkChecker. + 'linkcheckerlink', + // Redirect. + 'redirect', + // Salesforce. + 'salesforce_mapped_object', + // Webform. + 'webform_submission', ]; // Make a list of supported content types. diff --git a/web/modules/metatag/src/Form/MetatagDefaultsRevertForm.php b/web/modules/metatag/src/Form/MetatagDefaultsRevertForm.php index 1596d526a4f93730ee37fd3740a6448d963cd328..3b0e57f3fcbea0aeeaa425793c68e6df65a7cf4b 100644 --- a/web/modules/metatag/src/Form/MetatagDefaultsRevertForm.php +++ b/web/modules/metatag/src/Form/MetatagDefaultsRevertForm.php @@ -11,6 +11,13 @@ */ class MetatagDefaultsRevertForm extends EntityConfirmFormBase { + /** + * The Metatag defaults object being reverted. + * + * @var \Drupal\metatag\Entity\MetatagDefaults + */ + protected $entity; + /** * {@inheritdoc} */ @@ -36,7 +43,6 @@ public function getConfirmText() { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - /** @var \Drupal\metatag\Entity\MetatagDefaults $this->entity */ $this->entity->revert(); $this->messenger()->addMessage( diff --git a/web/modules/metatag/src/Form/MetatagSettingsForm.php b/web/modules/metatag/src/Form/MetatagSettingsForm.php index a111765c661d3b418f1ca0dc1b17bc49ef4d8c16..07e964df8c6778fc3365492ce45a24ab6d94b026 100644 --- a/web/modules/metatag/src/Form/MetatagSettingsForm.php +++ b/web/modules/metatag/src/Form/MetatagSettingsForm.php @@ -42,6 +42,13 @@ class MetatagSettingsForm extends ConfigFormBase { */ protected $tagPluginManager; + /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + /** * {@inheritdoc} */ @@ -54,6 +61,7 @@ public static function create(ContainerInterface $container) { $instance->metatagManager = $container->get('metatag.manager'); $instance->state = $container->get('state'); $instance->tagPluginManager = $container->get('plugin.manager.metatag.tag'); + $instance->moduleHandler = $container->get('module_handler'); return $instance; } @@ -140,13 +148,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; // Optional support for the Maxlenth module. - $form['tag_trim']['use_maxlength'] = array( + $form['tag_trim']['use_maxlength'] = [ '#type' => 'checkbox', '#title' => $this->t('Use Maxlength module to force these limits?'), '#default_value' => $this->config('metatag.settings')->get('use_maxlength') ?? TRUE, - '#description' => $this->t('Because of how tokens are processed in meta tags, use of the Maxlength module may not provide an accurate representation of the actual current length of each meta tag, so it may cause more problem than it is worth. '), - ); - if (!\Drupal::moduleHandler()->moduleExists('maxlength')) { + '#description' => $this->t('Because of how tokens are processed in meta tags, use of the Maxlength module may not provide an accurate representation of the actual current length of each meta tag, so it may cause more problem than it is worth.'), + ]; + if (!$this->moduleHandler->moduleExists('maxlength')) { $form['tag_trim']['use_maxlength']['#disabled'] = TRUE; $form['tag_trim']['use_maxlength']['#description'] = $this->t('Install the Maxlength module to enable this option.'); } diff --git a/web/modules/metatag/src/MetatagManager.php b/web/modules/metatag/src/MetatagManager.php index 06557829ed07ed0550604d28f7005d2c789e27cc..ddb679666cb400d7cbac82cb0550de5a53d1a93b 100644 --- a/web/modules/metatag/src/MetatagManager.php +++ b/web/modules/metatag/src/MetatagManager.php @@ -128,7 +128,8 @@ class MetatagManager implements MetatagManagerInterface { * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The Config Factory. */ - public function __construct(MetatagGroupPluginManager $groupPluginManager, + public function __construct( + MetatagGroupPluginManager $groupPluginManager, MetatagTagPluginManager $tagPluginManager, MetatagToken $token, LoggerChannelFactoryInterface $channelFactory, @@ -137,7 +138,7 @@ public function __construct(MetatagGroupPluginManager $groupPluginManager, RouteMatchInterface $routeMatch, RequestStack $requestStack, LanguageManagerInterface $languageManager, - ConfigFactoryInterface $config_factory + ConfigFactoryInterface $config_factory, ) { $this->groupPluginManager = $groupPluginManager; $this->tagPluginManager = $tagPluginManager; @@ -677,12 +678,6 @@ public function generateTokenValues(array $tags, $entity = NULL): array { ->getId(); } - // Use the entity's language code, if one is defined. - $langcode = NULL; - if ($entity) { - $langcode = $entity->language()->getId(); - } - if (!isset($this->processedTokenCache[$entity_identifier])) { $metatag_tags = $this->sortedTags(); diff --git a/web/modules/metatag/src/MetatagSeparator.php b/web/modules/metatag/src/MetatagSeparator.php index daf1a4f227a383353cc5d2e3ebf4882b01e5d12a..f8f54dbe273f0692db86b686537fbf9319456cac 100644 --- a/web/modules/metatag/src/MetatagSeparator.php +++ b/web/modules/metatag/src/MetatagSeparator.php @@ -30,7 +30,7 @@ public function getSeparator(): string { $config = $this->configFactory->get('metatag.settings'); // @todo This extra check shouldn't be needed. - if (!empty($config)) { + if ($config) { $separator = $config->get('separator'); } diff --git a/web/modules/metatag/src/MetatagToken.php b/web/modules/metatag/src/MetatagToken.php index eb7cdf110eb2ebd3bbe8538cc7eb90e77d2986ad..f74f10c014d4ac6f5d927187cfb2bf5cf32bbaf3 100644 --- a/web/modules/metatag/src/MetatagToken.php +++ b/web/modules/metatag/src/MetatagToken.php @@ -2,10 +2,10 @@ namespace Drupal\metatag; -use Drupal\Core\Utility\Token; use Drupal\Core\Render\BubbleableMetadata; -use Drupal\token\TokenEntityMapperInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\Utility\Token; +use Drupal\token\TokenEntityMapperInterface; /** * Token handling service. Uses core token service or contributed Token. diff --git a/web/modules/metatag/src/Plugin/Field/FieldFormatter/MetatagEmptyFormatter.php b/web/modules/metatag/src/Plugin/Field/FieldFormatter/MetatagEmptyFormatter.php index 06b6877d38118681b743beca95f6ff6e0c93ab87..6116e39352c8e269d817a3d40bd1517738a1be36 100644 --- a/web/modules/metatag/src/Plugin/Field/FieldFormatter/MetatagEmptyFormatter.php +++ b/web/modules/metatag/src/Plugin/Field/FieldFormatter/MetatagEmptyFormatter.php @@ -2,8 +2,8 @@ namespace Drupal\metatag\Plugin\Field\FieldFormatter; -use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\Core\Field\FormatterBase; /** * Plugin implementation of the 'metatag_empty_formatter' formatter. diff --git a/web/modules/metatag/src/Plugin/Field/MetatagEntityFieldItemList.php b/web/modules/metatag/src/Plugin/Field/MetatagEntityFieldItemList.php index 022c34a071710a23aec7b490caa2179443edbd0f..9ef912b5f3cd36ff0c9ce2829426fdb8b1786555 100644 --- a/web/modules/metatag/src/Plugin/Field/MetatagEntityFieldItemList.php +++ b/web/modules/metatag/src/Plugin/Field/MetatagEntityFieldItemList.php @@ -52,7 +52,7 @@ protected function computeValue() { $metatags_for_entity = $metatag_manager->tagsFromEntityWithDefaults($entity); // Trigger hook_metatags_alter(). - // Allow modules to override tags or the entity used for token replacements. + // Allow modules to override tags or entity used for token replacements. $context = [ 'entity' => &$entity, ]; diff --git a/web/modules/metatag/src/Plugin/diff/Field/MetatagFieldBuilder.php b/web/modules/metatag/src/Plugin/diff/Field/MetatagFieldBuilder.php index df74258255e6f139a9241fb0f3f5aec7ffcf260a..4eec569aecd10e091b2d9ad1508dc8381a212f5e 100644 --- a/web/modules/metatag/src/Plugin/diff/Field/MetatagFieldBuilder.php +++ b/web/modules/metatag/src/Plugin/diff/Field/MetatagFieldBuilder.php @@ -21,7 +21,7 @@ class MetatagFieldBuilder extends FieldDiffBuilderBase { /** * {@inheritdoc} */ - public function build(FieldItemListInterface $field_items) { + public function build(FieldItemListInterface $field_items): mixed { $result = []; // Every item from $field_items is of type FieldItemInterface. @@ -32,7 +32,7 @@ public function build(FieldItemListInterface $field_items) { // Metatag data store as serialize string. $metatag_data = metatag_data_decode($values['value']); - foreach ($metatag_data as $key => $value) { + foreach ($metatag_data as $value) { $result[$field_key][] = (string) $value; } } diff --git a/web/modules/metatag/src/Plugin/metatag/Tag/MetaNameBase.php b/web/modules/metatag/src/Plugin/metatag/Tag/MetaNameBase.php index b81386d5b692015efae9b724286f475f45b905d3..f0c94c119e9837cd96ea4c74eb17f0cbdb083280 100644 --- a/web/modules/metatag/src/Plugin/metatag/Tag/MetaNameBase.php +++ b/web/modules/metatag/src/Plugin/metatag/Tag/MetaNameBase.php @@ -17,8 +17,8 @@ /** * Each meta tag will extend this base. */ -abstract class MetaNameBase extends PluginBase {//implements ContainerFactoryPluginInterface { - +abstract class MetaNameBase extends PluginBase { + // Implements ContainerFactoryPluginInterface {. use MetatagSeparator; use StringTranslationTrait; @@ -431,7 +431,7 @@ public function form(array $element = []): array { if (!empty($trimlengths['metatag_maxlength_' . $this->id])) { $maxlength = intval($trimlengths['metatag_maxlength_' . $this->id]); if (is_numeric($maxlength) && $maxlength > 0) { - $form['#description'] .= ' ' . $this->t('This will be truncated to a maximum of %max characters after any tokens are processed.', array('%max' => $maxlength)); + $form['#description'] .= ' ' . $this->t('This will be truncated to a maximum of %max characters after any tokens are processed.', ['%max' => $maxlength]); // Optional support for the Maxlength module. if (\Drupal::moduleHandler()->moduleExists('maxlength')) { @@ -664,8 +664,8 @@ protected function trimValue($value): string { * * To skip testing the form field exists, return an empty array. * - * @return string - * An xpath-formatted string for matching a field on the form. + * @return array + * A list of xpath-formatted strings for matching a field on the form. */ public function getTestFormXpath(): array { // "Long" values use a text area on the form, so handle them automatically. diff --git a/web/modules/metatag/src/Plugin/metatag/Tag/Robots.php b/web/modules/metatag/src/Plugin/metatag/Tag/Robots.php index 6e0f930f37986666edd8da8733709ae6b573e857..652907aff7928d96e6a46de6b83fd2fdfbf35ef1 100644 --- a/web/modules/metatag/src/Plugin/metatag/Tag/Robots.php +++ b/web/modules/metatag/src/Plugin/metatag/Tag/Robots.php @@ -199,7 +199,7 @@ public function getTestOutputValuesXpath(array $values): array { $new_values[] = substr($form_field_name, 7, -1); } // Newer strings are stored with the form name "robots-keyed[something]", - // so those need the substring to be extracted and then + // so those need the substring to be extracted and then. elseif (strpos($form_field_name, 'robots-keyed[') !== FALSE) { $new_values[] = substr($form_field_name, 13, -1) . ':' . $value; } diff --git a/web/modules/metatag/src/Plugin/migrate/process/d6/NodewordsEntities.php b/web/modules/metatag/src/Plugin/migrate/process/d6/NodewordsEntities.php index 388dcc2e09a9c7c1b011ecd3e949eea44738cd22..167691bbfef2b90e7c28cdc7b2d3a2364e5fa269 100644 --- a/web/modules/metatag/src/Plugin/migrate/process/d6/NodewordsEntities.php +++ b/web/modules/metatag/src/Plugin/migrate/process/d6/NodewordsEntities.php @@ -347,7 +347,6 @@ public function tagsMap(): array { // @todo 'video:series' => '', // @todo 'video:tag' => '', // @todo 'video:writer' => '', - // From metatag_opengraph_products.metatag.inc: // https://www.drupal.org/project/metatag/issues/2835925 'product:price:amount' => 'product_price_amount', @@ -376,7 +375,6 @@ public function tagsMap(): array { // @todo 'product:shipping_weight:units' => '', // @todo 'product:expiration_time' => '', // @todo 'product:condition' => '', - // Pinterest. // @todo '' => 'pinterest_id', // @todo '' => 'pinterest_description', @@ -385,7 +383,6 @@ public function tagsMap(): array { // @todo '' => 'pinterest_media', // @todo '' => 'pinterest_nopin', // @todo '' => 'pinterest_nosearch', - // From metatag_twitter_cards.metatag.inc: 'twitter:app:country' => 'twitter_cards_app_store_country', 'twitter:app:id:googleplay' => 'twitter_cards_app_id_googleplay', diff --git a/web/modules/metatag/src/Plugin/migrate/process/d7/MetatagEntities.php b/web/modules/metatag/src/Plugin/migrate/process/d7/MetatagEntities.php index 63dc57c23edd88f6198be5ee25d289da523cad59..3f13c2b978d4b74a61484f4dd2ae10746f656dcb 100644 --- a/web/modules/metatag/src/Plugin/migrate/process/d7/MetatagEntities.php +++ b/web/modules/metatag/src/Plugin/migrate/process/d7/MetatagEntities.php @@ -374,7 +374,6 @@ protected function tagsMap(): array { // @todo 'product:shipping_weight:units' => '', // @todo 'product:expiration_time' => '', // @todo 'product:condition' => '', - // Pinterest. // @todo '' => 'pinterest_id', // @todo '' => 'pinterest_description', @@ -383,7 +382,6 @@ protected function tagsMap(): array { // @todo '' => 'pinterest_media', // @todo '' => 'pinterest_nopin', // @todo '' => 'pinterest_nosearch', - // From metatag_twitter_cards.metatag.inc: 'twitter:app:country' => 'twitter_cards_app_store_country', 'twitter:app:id:googleplay' => 'twitter_cards_app_id_googleplay', @@ -453,7 +451,7 @@ protected function tagsMap(): array { * A Metatag values array. */ private function decodeValue($string): array { - $data = array(); + $data = []; // Serialized arrays from Metatag v1. if (substr($string, 0, 2) === 'a:') { diff --git a/web/modules/metatag/src/Plugin/migrate/source/d7/MetatagFieldDeriver.php b/web/modules/metatag/src/Plugin/migrate/source/d7/MetatagFieldDeriver.php index 1f4c0be00a3d5d1d2a9a6830ab72800437898bdd..95499317ccc54091452b9dc4321dc946055b753e 100644 --- a/web/modules/metatag/src/Plugin/migrate/source/d7/MetatagFieldDeriver.php +++ b/web/modules/metatag/src/Plugin/migrate/source/d7/MetatagFieldDeriver.php @@ -70,7 +70,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { ->fetchAllKeyed(0, 0); foreach ($entity_type_ids as $entity_type_id) { // Skip if the entity type is missing. - if (!($entity_type_definition = $this->entityTypeManager->getDefinition($entity_type_id, FALSE))) { + if (!$this->entityTypeManager->getDefinition($entity_type_id, FALSE)) { continue; } diff --git a/web/modules/metatag/src/TypedData/ComputedItemListTrait.php b/web/modules/metatag/src/TypedData/ComputedItemListTrait.php index 21cf66f0795182a957fac0d69936bf5970322cfd..504a17a1e8192b7b49978a86c6c42ce52ef63398 100644 --- a/web/modules/metatag/src/TypedData/ComputedItemListTrait.php +++ b/web/modules/metatag/src/TypedData/ComputedItemListTrait.php @@ -40,6 +40,7 @@ protected function ensureComputedValue() { * This is run after the value has been computed at least once. * * @return bool + * State need for recomputing value. */ abstract protected function valueNeedsRecomputing(); diff --git a/web/modules/metatag/tests/fixtures/d8_metatag_v1.php b/web/modules/metatag/tests/fixtures/d8_metatag_v1.php index 996627ddedbee1647e97994da54702fcf8549b91..f26064bf8086a14d247ba23a03350dd55a3cebdc 100644 --- a/web/modules/metatag/tests/fixtures/d8_metatag_v1.php +++ b/web/modules/metatag/tests/fixtures/d8_metatag_v1.php @@ -7,14 +7,18 @@ /** * Notes on how to use this file. - * - When adding tests for changes to meta tags provided by a submodule, that - * submodule must be listed in the modules list below. - * - It is easiest to not add meta tag default configuration changes here that - * depend upon submodules, it works better to make those changes in the - * appropriate update script. - * - There is currently only one Metatag field defined, on the Article content - * type. - * - Each meta tag value to be tested is added to the fields lower down. + * + * When adding tests for changes to meta tags provided by a submodule, that + * submodule must be listed in the modules list below. + * + * It is easiest to not add meta tag default configuration changes here that + * depend upon submodules, it works better to make those changes in the + * appropriate update script. + * + * There is currently only one Metatag field defined, on the Article content + * type. + * + * Each meta tag value to be tested is added to the fields lower down. * * @todo Finish documenting this file. * @todo Expand to handle multiple languages. @@ -24,15 +28,21 @@ * @todo Work out a better way of handling field specification changes. */ -use Drupal\Core\Database\Database; use Drupal\Component\Serialization\Yaml; use Drupal\Component\Uuid\Php as Uuid; +use Drupal\Core\Database\Database; $config_fields = ['collection', 'name', 'data']; $keyvalue_fields = ['collection', 'name', 'value']; $connection = Database::getConnection(); +// Classes that are allowed in serialized arrays. +$allowed_classes = [ + 'Drupal\Core\Field\BaseFieldDefinition', + 'Drupal\field\Entity\FieldStorageConfig', +]; + // Enable Metatag (and Token). $extensions = $connection->select('config') ->fields('config', ['data']) @@ -40,7 +50,7 @@ ->condition('name', 'core.extension') ->execute() ->fetchField(); -$extensions = unserialize($extensions, ['allowed_classes' => []]); +$extensions = unserialize($extensions, ['allowed_classes' => FALSE]); $extensions['module']['metatag'] = 0; /** * Additional submodules must be added here if their meta tags are being tested. @@ -76,7 +86,7 @@ ->condition('name', 'existing_updates') ->execute() ->fetchField(); -$data = unserialize($data, ['allowed_classes' => []]); +$data = unserialize($data, ['allowed_classes' => FALSE]); $data[] = 'metatag_post_update_convert_author_config'; $data[] = 'metatag_post_update_convert_author_data'; $data[] = 'metatag_post_update_convert_mask_icon_to_array_values'; @@ -376,7 +386,7 @@ ->condition('name', 'node') ->execute() ->fetchField(); -$key_value = unserialize($key_value, ['allowed_classes' => []]); +$key_value = unserialize($key_value, ['allowed_classes' => FALSE]); $key_value['field_meta_tags'] = [ 'type' => 'metatag', 'bundles' => [ @@ -395,19 +405,20 @@ // messing with a serialized object. $key_value = $connection->select('key_value') ->fields('key_value', ['value']) - ->condition('collection', 'entity.definitions.installed') - ->condition('name', 'node.field_storage_definitions') + ->condition('collection', 'entity.definitions.installed') + ->condition('name', 'node.field_storage_definitions') ->execute() ->fetchField(); -$key_value = unserialize($key_value, ['allowed_classes' => [ - 'Drupal\Core\Field\BaseFieldDefinition', - 'Drupal\field\Entity\FieldStorageConfig', -]]); -$key_value['field_meta_tags'] = unserialize('O:38:"Drupal\field\Entity\FieldStorageConfig":35:{s:5:"' . "\0" . '*' . "\0" . 'id";s:20:"node.field_meta_tags";s:13:"' . "\0" . '*' . "\0" . 'field_name";s:15:"field_meta_tags";s:14:"' . "\0" . '*' . "\0" . 'entity_type";s:4:"node";s:7:"' . "\0" . '*' . "\0" . 'type";s:7:"metatag";s:9:"' . "\0" . '*' . "\0" . 'module";s:7:"metatag";s:11:"' . "\0" . '*' . "\0" . 'settings";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'cardinality";i:1;s:15:"' . "\0" . '*' . "\0" . 'translatable";b:1;s:9:"' . "\0" . '*' . "\0" . 'locked";b:0;s:25:"' . "\0" . '*' . "\0" . 'persist_with_no_fields";b:0;s:14:"custom_storage";b:0;s:10:"' . "\0" . '*' . "\0" . 'indexes";a:0:{}s:10:"' . "\0" . '*' . "\0" . 'deleted";b:0;s:13:"' . "\0" . '*' . "\0" . 'originalId";s:20:"node.field_meta_tags";s:9:"' . "\0" . '*' . "\0" . 'status";b:1;s:7:"' . "\0" . '*' . "\0" . 'uuid";s:36:"6aaab457-3728-4319-afa3-938e753ed342";s:11:"' . "\0" . '*' . "\0" . 'langcode";s:2:"en";s:23:"' . "\0" . '*' . "\0" . 'third_party_settings";a:0:{}s:8:"' . "\0" . '*' . "\0" . '_core";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'trustedData";b:0;s:15:"' . "\0" . '*' . "\0" . 'entityTypeId";s:20:"field_storage_config";s:15:"' . "\0" . '*' . "\0" . 'enforceIsNew";N;s:12:"' . "\0" . '*' . "\0" . 'typedData";N;s:16:"' . "\0" . '*' . "\0" . 'cacheContexts";a:0:{}s:12:"' . "\0" . '*' . "\0" . 'cacheTags";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'cacheMaxAge";i:-1;s:14:"' . "\0" . '*' . "\0" . '_serviceIds";a:0:{}s:18:"' . "\0" . '*' . "\0" . '_entityStorages";a:0:{}s:15:"' . "\0" . '*' . "\0" . 'dependencies";a:1:{s:6:"module";a:2:{i:0;s:7:"metatag";i:1;s:4:"node";}}s:12:"' . "\0" . '*' . "\0" . 'isSyncing";b:0;s:18:"cardinality_number";i:1;s:6:"submit";O:48:"Drupal\Core\StringTranslation\TranslatableMarkup":3:{s:9:"' . "\0" . '*' . "\0" . 'string";s:19:"Save field settings";s:12:"' . "\0" . '*' . "\0" . 'arguments";a:0:{}s:10:"' . "\0" . '*' . "\0" . 'options";a:0:{}}s:13:"form_build_id";s:48:"form-LK9HeARuUzcwIVvCAA4jG2MscwGjLAUJ9GLYxuzSo7o";s:10:"form_token";s:43:"eengi9MkLSqT-YFMEKD18fJ6cOvVyS_XRq1He7qhq4s";s:7:"form_id";s:30:"field_storage_config_edit_form";}}'); +$key_value = unserialize($key_value, [ + 'allowed_classes' => $allowed_classes, +]); +$key_value['field_meta_tags'] = unserialize('O:38:"Drupal\field\Entity\FieldStorageConfig":35:{s:5:"' . "\0" . '*' . "\0" . 'id";s:20:"node.field_meta_tags";s:13:"' . "\0" . '*' . "\0" . 'field_name";s:15:"field_meta_tags";s:14:"' . "\0" . '*' . "\0" . 'entity_type";s:4:"node";s:7:"' . "\0" . '*' . "\0" . 'type";s:7:"metatag";s:9:"' . "\0" . '*' . "\0" . 'module";s:7:"metatag";s:11:"' . "\0" . '*' . "\0" . 'settings";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'cardinality";i:1;s:15:"' . "\0" . '*' . "\0" . 'translatable";b:1;s:9:"' . "\0" . '*' . "\0" . 'locked";b:0;s:25:"' . "\0" . '*' . "\0" . 'persist_with_no_fields";b:0;s:14:"custom_storage";b:0;s:10:"' . "\0" . '*' . "\0" . 'indexes";a:0:{}s:10:"' . "\0" . '*' . "\0" . 'deleted";b:0;s:13:"' . "\0" . '*' . "\0" . 'originalId";s:20:"node.field_meta_tags";s:9:"' . "\0" . '*' . "\0" . 'status";b:1;s:7:"' . "\0" . '*' . "\0" . 'uuid";s:36:"6aaab457-3728-4319-afa3-938e753ed342";s:11:"' . "\0" . '*' . "\0" . 'langcode";s:2:"en";s:23:"' . "\0" . '*' . "\0" . 'third_party_settings";a:0:{}s:8:"' . "\0" . '*' . "\0" . '_core";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'trustedData";b:0;s:15:"' . "\0" . '*' . "\0" . 'entityTypeId";s:20:"field_storage_config";s:15:"' . "\0" . '*' . "\0" . 'enforceIsNew";N;s:12:"' . "\0" . '*' . "\0" . 'typedData";N;s:16:"' . "\0" . '*' . "\0" . 'cacheContexts";a:0:{}s:12:"' . "\0" . '*' . "\0" . 'cacheTags";a:0:{}s:14:"' . "\0" . '*' . "\0" . 'cacheMaxAge";i:-1;s:14:"' . "\0" . '*' . "\0" . '_serviceIds";a:0:{}s:18:"' . "\0" . '*' . "\0" . '_entityStorages";a:0:{}s:15:"' . "\0" . '*' . "\0" . 'dependencies";a:1:{s:6:"module";a:2:{i:0;s:7:"metatag";i:1;s:4:"node";}}s:12:"' . "\0" . '*' . "\0" . 'isSyncing";b:0;s:18:"cardinality_number";i:1;s:6:"submit";O:48:"Drupal\Core\StringTranslation\TranslatableMarkup":3:{s:9:"' . "\0" . '*' . "\0" . 'string";s:19:"Save field settings";s:12:"' . "\0" . '*' . "\0" . 'arguments";a:0:{}s:10:"' . "\0" . '*' . "\0" . 'options";a:0:{}}s:13:"form_build_id";s:48:"form-LK9HeARuUzcwIVvCAA4jG2MscwGjLAUJ9GLYxuzSo7o";s:10:"form_token";s:43:"eengi9MkLSqT-YFMEKD18fJ6cOvVyS_XRq1He7qhq4s";s:7:"form_id";s:30:"field_storage_config_edit_form";}}', [ + 'allowed_classes' => $allowed_classes, +]); $connection->update('key_value') ->fields(['value' => serialize($key_value)]) - ->condition('collection', 'entity.definitions.installed') - ->condition('name', 'node.field_storage_definitions') + ->condition('collection', 'entity.definitions.installed') + ->condition('name', 'node.field_storage_definitions') ->execute(); $connection->schema()->createTable('node__field_meta_tags', [ @@ -535,262 +546,262 @@ // Create a node with values. // @todo Create a few more. $connection->insert('comment_entity_statistics') -->fields([ - 'entity_id', - 'entity_type', - 'field_name', - 'cid', - 'last_comment_timestamp', - 'last_comment_name', - 'last_comment_uid', - 'comment_count', -]) -->values([ - 'entity_id' => '1', - 'entity_type' => 'node', - 'field_name' => 'comment', - 'cid' => '0', - 'last_comment_timestamp' => '1669762329', - 'last_comment_name' => NULL, - 'last_comment_uid' => '1', - 'comment_count' => '0', -]) -->execute(); + ->fields([ + 'entity_id', + 'entity_type', + 'field_name', + 'cid', + 'last_comment_timestamp', + 'last_comment_name', + 'last_comment_uid', + 'comment_count', + ]) + ->values([ + 'entity_id' => '1', + 'entity_type' => 'node', + 'field_name' => 'comment', + 'cid' => '0', + 'last_comment_timestamp' => '1669762329', + 'last_comment_name' => NULL, + 'last_comment_uid' => '1', + 'comment_count' => '0', + ]) + ->execute(); $connection->insert('node') -->fields([ - 'nid', - 'vid', - 'type', - 'uuid', - 'langcode', -]) -->values([ - 'nid' => '1', - 'vid' => '1', - 'type' => 'article', - 'uuid' => 'fc2c9449-df04-4d41-beea-5a5b39bf6b89', - 'langcode' => 'en', -]) -->execute(); + ->fields([ + 'nid', + 'vid', + 'type', + 'uuid', + 'langcode', + ]) + ->values([ + 'nid' => '1', + 'vid' => '1', + 'type' => 'article', + 'uuid' => 'fc2c9449-df04-4d41-beea-5a5b39bf6b89', + 'langcode' => 'en', + ]) + ->execute(); $connection->insert('node__comment') -->fields([ - 'bundle', - 'deleted', - 'entity_id', - 'revision_id', - 'langcode', - 'delta', - 'comment_status', -]) -->values([ - 'bundle' => 'article', - 'deleted' => '0', - 'entity_id' => '1', - 'revision_id' => '1', - 'langcode' => 'en', - 'delta' => '0', - 'comment_status' => '2', -]) -->execute(); + ->fields([ + 'bundle', + 'deleted', + 'entity_id', + 'revision_id', + 'langcode', + 'delta', + 'comment_status', + ]) + ->values([ + 'bundle' => 'article', + 'deleted' => '0', + 'entity_id' => '1', + 'revision_id' => '1', + 'langcode' => 'en', + 'delta' => '0', + 'comment_status' => '2', + ]) + ->execute(); $connection->insert('node__field_meta_tags') -->fields([ - 'bundle', - 'deleted', - 'entity_id', - 'revision_id', - 'langcode', - 'delta', - 'field_meta_tags_value', -]) -->values([ - 'bundle' => 'article', - 'deleted' => '0', - 'entity_id' => '1', - 'revision_id' => '1', - 'langcode' => 'en', - 'delta' => '0', + ->fields([ + 'bundle', + 'deleted', + 'entity_id', + 'revision_id', + 'langcode', + 'delta', + 'field_meta_tags_value', + ]) + ->values([ + 'bundle' => 'article', + 'deleted' => '0', + 'entity_id' => '1', + 'revision_id' => '1', + 'langcode' => 'en', + 'delta' => '0', /** * Expand this list as new meta tags need to be tested. */ - 'field_meta_tags_value' => serialize([ - 'description' => 'This is a Metatag v1 meta tag.', - 'title' => 'Testing | [site:name]', - 'robots' => 'index, nofollow, noarchive', + 'field_meta_tags_value' => serialize([ + 'description' => 'This is a Metatag v1 meta tag.', + 'title' => 'Testing | [site:name]', + 'robots' => 'index, nofollow, noarchive', // For #3065441. - 'google_plus_author' => 'GooglePlus Author tag test value for #3065441.', - 'google_plus_description' => 'GooglePlus Description tag test value for #3065441.', - 'google_plus_name' => 'GooglePlus Name tag test value for #3065441.', - 'google_plus_publisher' => 'GooglePlus Publisher tag test value for #3065441.', + 'google_plus_author' => 'GooglePlus Author tag test value for #3065441.', + 'google_plus_description' => 'GooglePlus Description tag test value for #3065441.', + 'google_plus_name' => 'GooglePlus Name tag test value for #3065441.', + 'google_plus_publisher' => 'GooglePlus Publisher tag test value for #3065441.', // For #2973351. - 'news_keywords' => 'News Keywords tag test value for #2973351.', - 'standout' => 'Standout tag test value for #2973351.', + 'news_keywords' => 'News Keywords tag test value for #2973351.', + 'standout' => 'Standout tag test value for #2973351.', // For #3132065. - 'twitter_cards_data1' => 'Data1 tag test for #3132065.', - 'twitter_cards_data2' => 'Data2 tag test for #3132065.', - 'twitter_cards_dnt' => 'Do Not Track tag test for #3132065.', - 'twitter_cards_gallery_image0' => 'Gallery Image0 tag test for #3132065.', - 'twitter_cards_gallery_image1' => 'Gallery Image1 tag test for #3132065.', - 'twitter_cards_gallery_image2' => 'Gallery Image2 tag test for #3132065.', - 'twitter_cards_gallery_image3' => 'Gallery Image3 tag test for #3132065.', - 'twitter_cards_image_height' => 'Image Height tag test for #3132065.', - 'twitter_cards_image_width' => 'Image Width tag test for #3132065.', - 'twitter_cards_label1' => 'Label1 tag test for #3132065.', - 'twitter_cards_label2' => 'Label2 tag test for #3132065.', - 'twitter_cards_page_url' => 'Page URL tag test for #3132065.', + 'twitter_cards_data1' => 'Data1 tag test for #3132065.', + 'twitter_cards_data2' => 'Data2 tag test for #3132065.', + 'twitter_cards_dnt' => 'Do Not Track tag test for #3132065.', + 'twitter_cards_gallery_image0' => 'Gallery Image0 tag test for #3132065.', + 'twitter_cards_gallery_image1' => 'Gallery Image1 tag test for #3132065.', + 'twitter_cards_gallery_image2' => 'Gallery Image2 tag test for #3132065.', + 'twitter_cards_gallery_image3' => 'Gallery Image3 tag test for #3132065.', + 'twitter_cards_image_height' => 'Image Height tag test for #3132065.', + 'twitter_cards_image_width' => 'Image Width tag test for #3132065.', + 'twitter_cards_label1' => 'Label1 tag test for #3132065.', + 'twitter_cards_label2' => 'Label2 tag test for #3132065.', + 'twitter_cards_page_url' => 'Page URL tag test for #3132065.', // For #3217263. - 'content_language' => 'Content Language tag test for #3217263.', + 'content_language' => 'Content Language tag test for #3217263.', // For #3132062. - 'twitter_cards_type' => 'gallery', + 'twitter_cards_type' => 'gallery', // For #3361816. - 'google_rating' => 'Google Rating tag test for #3361816', - ]), -]) -->execute(); + 'google_rating' => 'Google Rating tag test for #3361816', + ]), + ]) + ->execute(); $connection->insert('node_field_data') -->fields([ - 'nid', - 'vid', - 'type', - 'title', - 'created', - 'changed', - 'promote', - 'sticky', - 'revision_translation_affected', - 'default_langcode', - 'langcode', - 'status', - 'uid', -]) -->values([ - 'nid' => '1', - 'vid' => '1', - 'type' => 'article', - 'title' => 'Testing', - 'created' => '1669762311', - 'changed' => '1669762329', - 'promote' => '1', - 'sticky' => '0', - 'revision_translation_affected' => '1', - 'default_langcode' => '1', - 'langcode' => 'en', - 'status' => '1', - 'uid' => '1', -]) -->execute(); + ->fields([ + 'nid', + 'vid', + 'type', + 'title', + 'created', + 'changed', + 'promote', + 'sticky', + 'revision_translation_affected', + 'default_langcode', + 'langcode', + 'status', + 'uid', + ]) + ->values([ + 'nid' => '1', + 'vid' => '1', + 'type' => 'article', + 'title' => 'Testing', + 'created' => '1669762311', + 'changed' => '1669762329', + 'promote' => '1', + 'sticky' => '0', + 'revision_translation_affected' => '1', + 'default_langcode' => '1', + 'langcode' => 'en', + 'status' => '1', + 'uid' => '1', + ]) + ->execute(); $connection->insert('node_field_revision') -->fields([ - 'nid', - 'vid', - 'title', - 'created', - 'changed', - 'promote', - 'sticky', - 'revision_translation_affected', - 'default_langcode', - 'langcode', - 'status', - 'uid', -]) -->values([ - 'nid' => '1', - 'vid' => '1', - 'title' => 'Testing', - 'created' => '1669762311', - 'changed' => '1669762329', - 'promote' => '1', - 'sticky' => '0', - 'revision_translation_affected' => '1', - 'default_langcode' => '1', - 'langcode' => 'en', - 'status' => '1', - 'uid' => '1', -]) -->execute(); + ->fields([ + 'nid', + 'vid', + 'title', + 'created', + 'changed', + 'promote', + 'sticky', + 'revision_translation_affected', + 'default_langcode', + 'langcode', + 'status', + 'uid', + ]) + ->values([ + 'nid' => '1', + 'vid' => '1', + 'title' => 'Testing', + 'created' => '1669762311', + 'changed' => '1669762329', + 'promote' => '1', + 'sticky' => '0', + 'revision_translation_affected' => '1', + 'default_langcode' => '1', + 'langcode' => 'en', + 'status' => '1', + 'uid' => '1', + ]) + ->execute(); $connection->insert('node_revision__comment') -->fields([ - 'bundle', - 'deleted', - 'entity_id', - 'revision_id', - 'langcode', - 'delta', - 'comment_status', -]) -->values([ - 'bundle' => 'article', - 'deleted' => '0', - 'entity_id' => '1', - 'revision_id' => '1', - 'langcode' => 'en', - 'delta' => '0', - 'comment_status' => '2', -]) -->execute(); + ->fields([ + 'bundle', + 'deleted', + 'entity_id', + 'revision_id', + 'langcode', + 'delta', + 'comment_status', + ]) + ->values([ + 'bundle' => 'article', + 'deleted' => '0', + 'entity_id' => '1', + 'revision_id' => '1', + 'langcode' => 'en', + 'delta' => '0', + 'comment_status' => '2', + ]) + ->execute(); $connection->insert('node_revision__field_meta_tags') -->fields([ - 'bundle', - 'deleted', - 'entity_id', - 'revision_id', - 'langcode', - 'delta', - 'field_meta_tags_value', -]) -->values([ - 'bundle' => 'article', - 'deleted' => '0', - 'entity_id' => '1', - 'revision_id' => '1', - 'langcode' => 'en', - 'delta' => '0', + ->fields([ + 'bundle', + 'deleted', + 'entity_id', + 'revision_id', + 'langcode', + 'delta', + 'field_meta_tags_value', + ]) + ->values([ + 'bundle' => 'article', + 'deleted' => '0', + 'entity_id' => '1', + 'revision_id' => '1', + 'langcode' => 'en', + 'delta' => '0', /** * Expand this list as new meta tags need to be tested. */ - 'field_meta_tags_value' => serialize([ - 'description' => 'This is a Metatag v1 meta tag.', - 'title' => 'Testing | [site:name]', - 'robots' => 'index, nofollow, noarchive', + 'field_meta_tags_value' => serialize([ + 'description' => 'This is a Metatag v1 meta tag.', + 'title' => 'Testing | [site:name]', + 'robots' => 'index, nofollow, noarchive', // For #3065441. - 'google_plus_author' => 'GooglePlus Author tag test value for #3065441.', - 'google_plus_description' => 'GooglePlus Description tag test value for #3065441.', - 'google_plus_name' => 'GooglePlus Name tag test value for #3065441.', - 'google_plus_publisher' => 'GooglePlus Publisher tag test value for #3065441.', + 'google_plus_author' => 'GooglePlus Author tag test value for #3065441.', + 'google_plus_description' => 'GooglePlus Description tag test value for #3065441.', + 'google_plus_name' => 'GooglePlus Name tag test value for #3065441.', + 'google_plus_publisher' => 'GooglePlus Publisher tag test value for #3065441.', // For #2973351. - 'news_keywords' => 'News Keywords tag test value for #2973351.', - 'standout' => 'Standout tag test value for #2973351.', + 'news_keywords' => 'News Keywords tag test value for #2973351.', + 'standout' => 'Standout tag test value for #2973351.', // For #3132065. - 'twitter_cards_data1' => 'Data1 tag test for #3132065.', - 'twitter_cards_data2' => 'Data2 tag test for #3132065.', - 'twitter_cards_dnt' => 'Do Not Track tag test for #3132065.', - 'twitter_cards_gallery_image0' => 'Gallery Image0 tag test for #3132065.', - 'twitter_cards_gallery_image1' => 'Gallery Image1 tag test for #3132065.', - 'twitter_cards_gallery_image2' => 'Gallery Image2 tag test for #3132065.', - 'twitter_cards_gallery_image3' => 'Gallery Image3 tag test for #3132065.', - 'twitter_cards_image_height' => 'Image Height tag test for #3132065.', - 'twitter_cards_image_width' => 'Image Width tag test for #3132065.', - 'twitter_cards_label1' => 'Label1 tag test for #3132065.', - 'twitter_cards_label2' => 'Label2 tag test for #3132065.', - 'twitter_cards_page_url' => 'Page URL tag test for #3132065.', + 'twitter_cards_data1' => 'Data1 tag test for #3132065.', + 'twitter_cards_data2' => 'Data2 tag test for #3132065.', + 'twitter_cards_dnt' => 'Do Not Track tag test for #3132065.', + 'twitter_cards_gallery_image0' => 'Gallery Image0 tag test for #3132065.', + 'twitter_cards_gallery_image1' => 'Gallery Image1 tag test for #3132065.', + 'twitter_cards_gallery_image2' => 'Gallery Image2 tag test for #3132065.', + 'twitter_cards_gallery_image3' => 'Gallery Image3 tag test for #3132065.', + 'twitter_cards_image_height' => 'Image Height tag test for #3132065.', + 'twitter_cards_image_width' => 'Image Width tag test for #3132065.', + 'twitter_cards_label1' => 'Label1 tag test for #3132065.', + 'twitter_cards_label2' => 'Label2 tag test for #3132065.', + 'twitter_cards_page_url' => 'Page URL tag test for #3132065.', // For #3217263. - 'content_language' => 'Content Language tag test for #3217263.', + 'content_language' => 'Content Language tag test for #3217263.', // For #3132062. - 'twitter_cards_type' => 'gallery', + 'twitter_cards_type' => 'gallery', // For #3361816. - 'google_rating' => 'Google Rating tag test for #3361816', - ]), -]) -->execute(); + 'google_rating' => 'Google Rating tag test for #3361816', + ]), + ]) + ->execute(); diff --git a/web/modules/metatag/tests/modules/metatag_test_custom_route/metatag_test_custom_route.info.yml b/web/modules/metatag/tests/modules/metatag_test_custom_route/metatag_test_custom_route.info.yml index c00d4a736e998f2cc0f77f758b5db649d49db563..d881fa5c582929ccdc8afde50dd4e81d78e34d85 100644 --- a/web/modules/metatag/tests/modules/metatag_test_custom_route/metatag_test_custom_route.info.yml +++ b/web/modules/metatag/tests/modules/metatag_test_custom_route/metatag_test_custom_route.info.yml @@ -5,7 +5,7 @@ package: Testing dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/tests/modules/metatag_test_custom_route/src/Controller/MetatagTestCustomRouteController.php b/web/modules/metatag/tests/modules/metatag_test_custom_route/src/Controller/MetatagTestCustomRouteController.php index 24a537cd1cc9303f64f1cc9ac5348b6f8b6d71c9..98769a183f1d7847f1ea95c2f7d4fb91108c3ad0 100644 --- a/web/modules/metatag/tests/modules/metatag_test_custom_route/src/Controller/MetatagTestCustomRouteController.php +++ b/web/modules/metatag/tests/modules/metatag_test_custom_route/src/Controller/MetatagTestCustomRouteController.php @@ -14,7 +14,7 @@ class MetatagTestCustomRouteController extends ControllerBase { */ public function test() { $render = [ - '#markup' => $this->t('<p>Hello world!</p>'), + '#markup' => '<p>Hello world!</p>', ]; return $render; diff --git a/web/modules/metatag/tests/modules/metatag_test_integration/metatag_test_integration.info.yml b/web/modules/metatag/tests/modules/metatag_test_integration/metatag_test_integration.info.yml index 0063c74c48ebca8cc3fa4d01dfcd06bdc7035c4d..dec5cc84def2647b17a735688769f5bdb2c7db91 100644 --- a/web/modules/metatag/tests/modules/metatag_test_integration/metatag_test_integration.info.yml +++ b/web/modules/metatag/tests/modules/metatag_test_integration/metatag_test_integration.info.yml @@ -5,7 +5,7 @@ package: Testing dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/tests/modules/metatag_test_tag/metatag_test_tag.info.yml b/web/modules/metatag/tests/modules/metatag_test_tag/metatag_test_tag.info.yml index 0f90fed6fc0762f2f60c7fcd0e2476303325f929..580613c2409fe8041de3f77626fd91dd9dbb137e 100644 --- a/web/modules/metatag/tests/modules/metatag_test_tag/metatag_test_tag.info.yml +++ b/web/modules/metatag/tests/modules/metatag_test_tag/metatag_test_tag.info.yml @@ -5,7 +5,7 @@ package: Testing dependencies: - metatag:metatag -# Information added by Drupal.org packaging script on 2023-06-27 -version: '2.0.0' +# Information added by Drupal.org packaging script on 2024-08-05 +version: '2.0.2' project: 'metatag' -datestamp: 1687856985 +datestamp: 1722869775 diff --git a/web/modules/metatag/tests/src/Functional/DefaultTags.php b/web/modules/metatag/tests/src/Functional/DefaultTagsTest.php similarity index 99% rename from web/modules/metatag/tests/src/Functional/DefaultTags.php rename to web/modules/metatag/tests/src/Functional/DefaultTagsTest.php index 6573aa457bb395bfc14ea3074eea7047ad4d0ff2..6a4e8f33cd82c645c809bfb91af0bbe83e068189 100644 --- a/web/modules/metatag/tests/src/Functional/DefaultTags.php +++ b/web/modules/metatag/tests/src/Functional/DefaultTagsTest.php @@ -9,7 +9,7 @@ * * @group metatag */ -class DefaultTags extends BrowserTestBase { +class DefaultTagsTest extends BrowserTestBase { // Contains helper methods. use MetatagHelperTrait; diff --git a/web/modules/metatag/tests/src/Functional/EnsureDevelWebProfilerWorks.php b/web/modules/metatag/tests/src/Functional/EnsureDevelWebProfilerWorks.php deleted file mode 100644 index 015f810a3858879aeb6b33ffceb80202705e2c2a..0000000000000000000000000000000000000000 --- a/web/modules/metatag/tests/src/Functional/EnsureDevelWebProfilerWorks.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Drupal\Tests\metatag\Functional; - -/** - * Verify that enabling WebProfiler won't cause the site to blow up. - * - * @group metatag - */ -class EnsureDevelWebProfilerWorks extends EnsureDevelWorks { - - /** - * {@inheritdoc} - */ - protected static $modules = [ - // Modules for core functionality. - 'node', - 'field', - 'field_ui', - 'user', - - // Contrib dependencies. - 'token', - - // This module. - 'metatag', - - // Use the custom route to verify the site works. - 'metatag_test_custom_route', - - // The modules to test. - 'devel', - 'webprofiler', - ]; - -} diff --git a/web/modules/metatag/tests/src/Functional/EnsureDevelWorks.php b/web/modules/metatag/tests/src/Functional/EnsureDevelWorks.php deleted file mode 100644 index 9a492900d6e2a66ac0bd1d2f06c3a0b03d0bc7d3..0000000000000000000000000000000000000000 --- a/web/modules/metatag/tests/src/Functional/EnsureDevelWorks.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -namespace Drupal\Tests\metatag\Functional; - -use Drupal\Tests\BrowserTestBase; - -/** - * Verify that enabling Devel won't cause the site to blow up. - * - * @group metatag - */ -class EnsureDevelWorks extends BrowserTestBase { - - // Contains helper methods. - use MetatagHelperTrait; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - // Modules for core functionality. - 'node', - 'field', - 'field_ui', - 'user', - - // Contrib dependencies. - 'token', - - // This module. - 'metatag', - - // Use the custom route to verify the site works. - 'metatag_test_custom_route', - - // The modules to test. - 'devel', - ]; - - /** - * Load the custom route, make sure something is output. - */ - public function testCustomRoute() { - $this->drupalGet('metatag_test_custom_route'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Hello world!'); - } - - /** - * Make sure that the system still works when some example content exists. - */ - public function testNode() { - $node = $this->createContentTypeNode(); - $this->drupalGet($node->toUrl()); - $this->assertSession()->statusCodeEquals(200); - } - -} diff --git a/web/modules/metatag/tests/src/Functional/EntityTestMetatagTest.php b/web/modules/metatag/tests/src/Functional/EntityTestMetatagTest.php index fd964fee76e3aef91abf36ce160513ea3153126c..ae106296fe373d919356a21afbc1085f9ae1b2d8 100644 --- a/web/modules/metatag/tests/src/Functional/EntityTestMetatagTest.php +++ b/web/modules/metatag/tests/src/Functional/EntityTestMetatagTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\metatag\Functional; use Drupal\Component\Serialization\Json; -use Drupal\Core\Cache\Cache; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -93,7 +92,7 @@ protected function createEntity() { 'type' => 'entity_test', 'field_metatag' => [ 'value' => [ - 'description' => 'This is a description for use in Search Engines' + 'description' => 'This is a description for use in Search Engines', ], ], ]); diff --git a/web/modules/metatag/tests/src/Functional/MaintenanceMode.php b/web/modules/metatag/tests/src/Functional/MaintenanceModeTest.php similarity index 96% rename from web/modules/metatag/tests/src/Functional/MaintenanceMode.php rename to web/modules/metatag/tests/src/Functional/MaintenanceModeTest.php index 1bd3cd8f0e1922278e3c576acaf9f9102ccd0494..ad24a72967c0a75f3b31f25efd8b79812a906bf8 100644 --- a/web/modules/metatag/tests/src/Functional/MaintenanceMode.php +++ b/web/modules/metatag/tests/src/Functional/MaintenanceModeTest.php @@ -10,7 +10,7 @@ * * @group metatag */ -class MaintenanceMode extends BrowserTestBase { +class MaintenanceModeTest extends BrowserTestBase { // Contains helper methods. use MetatagHelperTrait; diff --git a/web/modules/metatag/tests/src/Functional/MetatagAdminTest.php b/web/modules/metatag/tests/src/Functional/MetatagAdminTest.php index 10c26d385f4e374ab16078e794e411c2561620ae..8ebf28ff15710b0928695719cc41e49af1213bc7 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagAdminTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagAdminTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\metatag\Functional; -use Drupal\metatag\MetatagManager; use Drupal\metatag\Entity\MetatagDefaults; +use Drupal\metatag\MetatagManager; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** * Tests the Metatag administration. @@ -14,8 +14,8 @@ */ class MetatagAdminTest extends BrowserTestBase { + use FieldUiTestTrait; use MetatagHelperTrait; - use StringTranslationTrait; /** * {@inheritdoc} @@ -127,7 +127,7 @@ public function testDefaults() { drupal_flush_all_caches(); $this->drupalGet('hit-a-404'); $session->statusCodeEquals(404); - foreach ($values as $metatag => $value) { + foreach ($values as $value) { $processed_value = \Drupal::token()->replace($value); $session->responseContains($processed_value); } @@ -278,7 +278,7 @@ public function testOverrides() { // Create a test node. $node = $this->drupalCreateNode([ - 'title' => $this->t('Hello, world!'), + 'title' => 'Hello, world!', 'type' => 'article', ]); @@ -318,7 +318,7 @@ public function testOverrides() { // performant than creating a node for every set of assertions. // @see BookTest::testDelete() $node = $this->drupalCreateNode([ - 'title' => $this->t('Hello, world!'), + 'title' => 'Hello, world!', 'type' => 'article', ]); $this->drupalGet('node/' . $node->id()); @@ -340,7 +340,7 @@ public function testOverrides() { // Confirm the fields load properly on the node/add/article page. $node = $this->drupalCreateNode([ - 'title' => $this->t('Hello, world!'), + 'title' => 'Hello, world!', 'type' => 'article', ]); $this->drupalGet('node/' . $node->id()); @@ -379,19 +379,8 @@ public function testEntityDefaultInheritence() { $this->drupalLogin($account); // Add a Metatag field to the Article content type. - $this->drupalGet('admin/structure/types/manage/article/fields/add-field'); $session = $this->assertSession(); - $session->statusCodeEquals(200); - $edit = [ - 'new_storage_type' => 'metatag', - 'label' => 'Meta tags', - 'field_name' => 'meta_tags', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $this->submitForm([], $this->t('Save field settings')); - $session->pageTextContains(strip_tags('Updated field Meta tags field settings.')); - $this->submitForm([], $this->t('Save settings')); - $session->pageTextContains(strip_tags('Saved Meta tags configuration.')); + $this->fieldUIAddNewField('admin/structure/types/manage/article', 'meta_tags', 'Metatag', 'metatag'); // Try creating an article, confirm the fields are present. This should be // the node default values that are shown. diff --git a/web/modules/metatag/tests/src/Functional/MetatagTagTypesTest.php b/web/modules/metatag/tests/src/Functional/MetatagApiTest.php similarity index 78% rename from web/modules/metatag/tests/src/Functional/MetatagTagTypesTest.php rename to web/modules/metatag/tests/src/Functional/MetatagApiTest.php index 9975c7330eb4ec3746829e12cddb3c676ea2362b..459f4a62ba20b2155cebe9ee3fe5c6fd69c01eb9 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagTagTypesTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagApiTest.php @@ -3,16 +3,16 @@ namespace Drupal\Tests\metatag\Functional; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** - * Verify that different meta tag API options are supported. + * Verify that different API options are supported. * * @group metatag */ class MetatagApiTest extends BrowserTestBase { - use StringTranslationTrait; + use FieldUiTestTrait; /** * Profile to use. @@ -40,9 +40,6 @@ class MetatagApiTest extends BrowserTestBase { // Needed for the field UI testing. 'field_ui', - // Needed for the basic entity testing. - 'entity_test', - // Needed to verify that nothing is broken for unsupported entities. 'contact', @@ -68,10 +65,10 @@ class MetatagApiTest extends BrowserTestBase { */ protected $permissions = [ 'access administration pages', - 'view test entity', - 'administer entity_test fields', - 'administer entity_test content', 'administer meta tags', + // 'view test entity', + // 'administer entity_test fields', + // 'administer entity_test content', ]; /** @@ -83,17 +80,14 @@ protected function setUp(): void { $this->drupalLogin($this->adminUser); // Add a metatag field to the entity type test_entity. - $this->drupalGet('entity_test/structure/entity_test/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $this->submitForm([], $this->t('Save field settings')); - $this->container->get('entity_field.manager') - ->clearCachedFieldDefinitions(); + // @todo Work out a better solution for this, as the entity type is not + // actually used. + // @code + // phpcs:ignore + // $this->fieldUIAddNewField('admin/structure/types/manage/entity_test', 'metatag', 'Metatag', 'metatag'); + // $this->container->get('entity_field.manager') + // ->clearCachedFieldDefinitions(); + // @endcode } /** @@ -175,26 +169,32 @@ public function testContactForm() { */ public function todoTestUrl() { // @code - // $save_label = (floatval(\Drupal::VERSION) <= 8.3) ? $this->t('Save and publish') : $this->t('Save'); + // $save_label = (floatval(\Drupal::VERSION) <= 8.3) ? + // 'Save and publish' : 'Save'; // // Tests meta tags with URLs work. // $this->drupalGet($this->entity_add_path); // $this->assertSession()->statusCodeEquals(200); + // $url_test = 'https://example.com/foo.html'; // $edit = [ - // 'name[0][value]' => 'UrlTags', - // 'user_id[0][target_id]' => 'foo (' . $this->adminUser->id() . ')', - // 'field_metatag[0][advanced][original_source]' => 'https://example.com/foo.html', + // 'name[0][value]' => 'UrlTags', + // 'user_id[0][target_id]' => 'foo (' . $this->adminUser->id() . ')', + // 'field_metatag[0][advanced][original_source]' => $url_test, // ]; // $this->submitForm($edit, $save_label); // $entities = entity_load_multiple_by_properties('entity_test', [ - // 'name' => 'UrlTags', + // 'name' => 'UrlTags', // ]); // $this->assertEquals(count($entities), 1, 'Entity was saved'); // $entity = reset($entities); // $this->drupalGet($this->entity_base_path . '/' . $entity->id()); // $this->assertSession()->statusCodeEquals(200); // $elements = $this->cssSelect("meta[name='original-source']"); - // $this->assertTrue(count($elements) === 1, 'Found original source metatag from defaults'); - // $this->assertEquals($edit['field_metatag[0][advanced][original_source]'], (string) $elements[0]['content']); + // $message_assert = 'Found original source metatag from defaults'; + // $this->assertTrue(count($elements) === 1, $message_assert); + // $this->assertEquals( + // $edit['field_metatag[0][advanced][original_source]'], + // (string) $elements[0]['content'] + // ); // @endcode } diff --git a/web/modules/metatag/tests/src/Functional/MetatagConfigTranslationTest.php b/web/modules/metatag/tests/src/Functional/MetatagConfigTranslationTest.php index 32fab439d7dffc1329d83b835a6a7bb8383d3a30..d8ec87898fa0d07dadc0c02accd1249bde0e3f1e 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagConfigTranslationTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagConfigTranslationTest.php @@ -5,7 +5,6 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\metatag\Entity\MetatagDefaults; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Ensures that the Metatag config translations work correctly. @@ -14,8 +13,6 @@ */ class MetatagConfigTranslationTest extends BrowserTestBase { - use StringTranslationTrait; - /** * Profile to use. * @@ -90,7 +87,7 @@ public function testConfigTranslationsExist() { $this->drupalGet('admin/config/regional/config-translation/metatag_defaults'); $session->statusCodeEquals(200); // @todo Update this to confirm the H1 is loaded. - $session->responseContains($this->t('Metatag defaults')); + $session->responseContains('Metatag defaults'); // Load all of the Metatag defaults. $defaults = \Drupal::configFactory()->listAll('metatag.metatag_defaults'); @@ -128,7 +125,7 @@ public function testConfigTranslations() { 'title' => 'Test title', 'description' => 'Test description', ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $session->statusCodeEquals(200); $session->pageTextContains('Saved the Global Metatag defaults.'); @@ -153,7 +150,7 @@ public function testConfigTranslations() { 'translation[config_names][metatag.metatag_defaults.global][tags][title]' => 'Le title', 'translation[config_names][metatag.metatag_defaults.global][tags][description]' => 'Le description', ]; - $this->submitForm($edit, $this->t('Save translation')); + $this->submitForm($edit, 'Save translation'); $session->statusCodeEquals(200); $session->pageTextContains('Successfully saved French translation'); diff --git a/web/modules/metatag/tests/src/Functional/MetatagCustomRouteTest.php b/web/modules/metatag/tests/src/Functional/MetatagCustomRouteTest.php index 7b158628f63e2159f64d31db0e43d61807888a58..7a426b2f61159fa4a18ed6d53fb78f0269fb9dd5 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagCustomRouteTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagCustomRouteTest.php @@ -13,7 +13,7 @@ * * @see hook_metatag_route_entity() */ -class CustomRouteTest extends BrowserTestBase { +class MetatagCustomRouteTest extends BrowserTestBase { /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/MetatagFieldNodeTest.php b/web/modules/metatag/tests/src/Functional/MetatagFieldNodeTest.php index 25bc6da4fa72f504b5b1d8aaac3454526ed2d367..76425b119422a94c94add7acf61a0c13acfca668 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFieldNodeTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFieldNodeTest.php @@ -72,7 +72,7 @@ class MetatagFieldNodeTest extends MetatagFieldTestBase { /** * {@inheritdoc} */ - protected $entityFieldAdminPath = 'admin/structure/types/manage/page/fields'; + protected $entityFieldAdminPath = 'admin/structure/types/manage/page'; /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/MetatagFieldTermTest.php b/web/modules/metatag/tests/src/Functional/MetatagFieldTermTest.php index e3ca21988c754c3df8d4a8d31bddfb3132de401d..5f2be9847ee1a5a826eb37cd6214b8342cdc2cbf 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFieldTermTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFieldTermTest.php @@ -2,8 +2,6 @@ namespace Drupal\Tests\metatag\Functional; -use Drupal\Core\StringTranslation\StringTranslationTrait; - /** * Ensures that the Metatag field works correctly on taxonomy terms. * @@ -11,8 +9,6 @@ */ class MetatagFieldTermTest extends MetatagFieldTestBase { - use StringTranslationTrait; - /** * {@inheritdoc} */ @@ -72,7 +68,7 @@ class MetatagFieldTermTest extends MetatagFieldTestBase { /** * {@inheritdoc} */ - protected $entityFieldAdminPath = 'admin/structure/taxonomy/manage/tags/overview/fields'; + protected $entityFieldAdminPath = 'admin/structure/taxonomy/manage/tags/overview'; /** * {@inheritdoc} @@ -96,7 +92,7 @@ protected function setUpEntityType(): void { 'name' => 'Tags', 'vid' => 'tags', ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $this->drupalLogout(); } diff --git a/web/modules/metatag/tests/src/Functional/MetatagFieldTestBase.php b/web/modules/metatag/tests/src/Functional/MetatagFieldTestBase.php index ec5d308d205ec55314ba71fd8f831be9a33770a1..55a7ab60a965a32619ee8c7c6499b3ecf808db1c 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFieldTestBase.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFieldTestBase.php @@ -5,12 +5,14 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** * Base class for ensuring that the Metatag field works correctly. */ abstract class MetatagFieldTestBase extends BrowserTestBase { + use FieldUiTestTrait; use StringTranslationTrait; /** @@ -168,15 +170,7 @@ protected function entityDefaultValues($title = 'Barfoo'): array { */ protected function addField(): void { // Add a metatag field to the entity type test_entity. - $this->drupalGet($this->entityFieldAdminPath . '/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $this->submitForm([], $this->t('Save field settings')); + $this->fieldUIAddNewField($this->entityFieldAdminPath, 'metatag', 'Metatag', 'metatag'); // Clear all settings. $this->container->get('entity_field.manager')->clearCachedFieldDefinitions(); @@ -244,9 +238,6 @@ public function testEntityDefaultsInheritance() { $session->statusCodeEquals(200); $session->pageTextNotContains('Fatal error'); - // Allow the fields to be customized if needed. - $edit = $this->entityDefaultValues('Barfoo'); - // If this entity type supports defaults then verify the global default is // not present but that the entity default *is* present. $session->fieldValueEquals('field_metatag[0][basic][metatag_test_tag]', $entity_values['metatag_test_tag']); @@ -267,10 +258,10 @@ public function testBundleDefaultsInheritance() { * Confirm a field can be added to the entity bundle. */ public function testFieldCanBeAdded() { - $this->drupalGet($this->entityFieldAdminPath . '/add-field'); + $this->drupalGet($this->entityFieldAdminPath . '/fields/add-field'); $session = $this->assertSession(); $session->statusCodeEquals(200); - $session->responseContains('<option value="metatag">' . $this->t('Meta tags') . '</option>'); + $session->elementExists('css', 'label:contains("Meta tags")'); } /** @@ -430,8 +421,8 @@ public function testEntityFieldValuesNewEntity() { // @todo Confirm the values output correctly. // Check the output. // @todo Test this. - $all_tags = metatag_generate_entity_all_tags($entity); - $overrides = metatag_generate_entity_overrides($entity); + metatag_generate_entity_all_tags($entity); + metatag_generate_entity_overrides($entity); } /** @@ -451,7 +442,7 @@ public function todoTestEntityField() { $edit = $this->entityDefaultValues() + [ 'field_metatag[0][basic][metatag_test_tag]' => 'Kilimanjaro', ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $entities = \Drupal::entityTypeManager() ->getStorage('entity_test') ->loadByProperties([$this->entityTitleField => 'Barfoo']); diff --git a/web/modules/metatag/tests/src/Functional/MetatagFieldTestTest.php b/web/modules/metatag/tests/src/Functional/MetatagFieldTestTest.php index fb54470a95ca3ba125dc9cfbb426ca00ab941e0c..43878f4a2791ccc83269e0453de7a09247316b5d 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFieldTestTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFieldTestTest.php @@ -64,7 +64,7 @@ class MetatagFieldTestTest extends MetatagFieldTestBase { /** * {@inheritdoc} */ - protected $entityFieldAdminPath = 'entity_test/structure/entity_test/fields'; + protected $entityFieldAdminPath = 'entity_test/structure/entity_test'; /** * Whether or not the entity type supports defaults. diff --git a/web/modules/metatag/tests/src/Functional/MetatagFieldUserTest.php b/web/modules/metatag/tests/src/Functional/MetatagFieldUserTest.php index bfef61ebd4a533265a3671ba63806f285ea0c493..a8cdf8837a4f45c95b8b938bca95b87efe6df33c 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFieldUserTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFieldUserTest.php @@ -67,7 +67,7 @@ class MetatagFieldUserTest extends MetatagFieldTestBase { /** * {@inheritdoc} */ - protected $entityFieldAdminPath = 'admin/config/people/accounts/fields'; + protected $entityFieldAdminPath = 'admin/config/people/accounts'; /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/MetatagForumTest.php b/web/modules/metatag/tests/src/Functional/MetatagForumTest.php index 49cd5e5be47e74b2ac83462d3c1af3268b7f135e..d1d830079cf719bed48fc0ce3c049438b9c2d8f9 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagForumTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagForumTest.php @@ -2,15 +2,15 @@ namespace Drupal\Tests\metatag\Functional; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\BrowserTestBase; /** * Ensures that meta tags are rendering correctly on forum pages. * * @group metatag */ -class ForumTest extends BrowserTestBase { +class MetatagForumTest extends BrowserTestBase { use StringTranslationTrait; diff --git a/web/modules/metatag/tests/src/Functional/MetatagFrontpageTest.php b/web/modules/metatag/tests/src/Functional/MetatagFrontpageTest.php index 98af295cba6aa107291686bc6531f5de106cec3e..65366800ecb2f95e0d20781ea646e60c65880182 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagFrontpageTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagFrontpageTest.php @@ -3,17 +3,15 @@ namespace Drupal\Tests\metatag\Functional; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Ensures that meta tags are rendering correctly on home page. * * @group metatag */ -class FrontpageTest extends BrowserTestBase { +class MetatagFrontpageTest extends BrowserTestBase { use MetatagHelperTrait; - use StringTranslationTrait; /** * {@inheritdoc} @@ -76,7 +74,7 @@ public function testFrontPageMetatagsEnabledConfig() { 'description' => 'Test description', 'keywords' => 'testing,keywords', ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $session->statusCodeEquals(200); $session->pageTextContains('Saved the Front page Metatag defaults.'); @@ -121,19 +119,21 @@ public function testFrontPageMetatagsEnabledConfig() { ]; $this->drupalGet('admin/config/system/site-information'); $session->statusCodeEquals(200); - $this->submitForm($site_edit, $this->t('Save configuration')); + $this->submitForm($site_edit, 'Save configuration'); $session->pageTextContains('The configuration options have been saved.'); - return; // @todo Finish this? - $this->drupalGet('test-page'); - $session->statusCodeEquals(200); - foreach ($edit as $metatag => $metatag_value) { - $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); - $this->assertCount(1, $xpath, 'Exactly one ' . $metatag . ' meta tag found.'); - $value = $xpath[0]->getAttribute('content'); - $this->assertEquals($value, $metatag_value); - } + // @code + // $this->drupalGet('test-page'); + // $session->statusCodeEquals(200); + // foreach ($edit as $metatag => $metatag_value) { + // $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); + // $assert_message = 'Exactly one ' . $metatag . ' meta tag found.'; + // $this->assertCount(1, $xpath, $assert_message); + // $value = $xpath[0]->getAttribute('content'); + // $this->assertEquals($value, $metatag_value); + // } + // @endcode } /** @@ -144,7 +144,7 @@ public function testFrontPageMetatagDisabledConfig() { $this->drupalGet('admin/config/search/metatag/front/delete'); $session = $this->assertSession(); $session->statusCodeEquals(200); - $this->submitForm([], $this->t('Delete')); + $this->submitForm([], 'Delete'); $session->statusCodeEquals(200); $session->pageTextContains('Deleted Front page defaults.'); @@ -179,7 +179,7 @@ public function testFrontPageMetatagDisabledConfig() { $edit = [ 'site_frontpage' => '/test-page', ]; - $this->submitForm($edit, $this->t('Save configuration')); + $this->submitForm($edit, 'Save configuration'); $session->pageTextContains('The configuration options have been saved.'); // Front page is custom route. diff --git a/web/modules/metatag/tests/src/Functional/MetatagHelperTrait.php b/web/modules/metatag/tests/src/Functional/MetatagHelperTrait.php index 343c0b78747cf3291f9341b444ede0d60d37df97..d1bf11b06421b2b3076470a74e07bb2c7a0d802d 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagHelperTrait.php +++ b/web/modules/metatag/tests/src/Functional/MetatagHelperTrait.php @@ -113,7 +113,7 @@ private function createVocabulary(array $values = []): VocabularyInterface { * @param array $values * Items passed to the term. Requires the 'vid' element. * - * @return \Drupal\taxonomy\Term + * @return \Drupal\taxonomy\Entity\Term * A fully formatted term object. */ private function createTerm(array $values = []): TermInterface { diff --git a/web/modules/metatag/tests/src/Functional/MetatagIntegrationTest.php b/web/modules/metatag/tests/src/Functional/MetatagIntegrationTest.php index 8a7ff1d80e9c8b7cb840014b60bb1f7c7456973c..22d5139666e7aa3a518b7f8a7a491bc83343c44d 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagIntegrationTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagIntegrationTest.php @@ -9,7 +9,7 @@ * * @group metatag */ -class MetatagHooksTest extends BrowserTestBase { +class MetatagIntegrationTest extends BrowserTestBase { /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/MetatagNodeTranslationTest.php b/web/modules/metatag/tests/src/Functional/MetatagNodeTranslationTest.php index da753410a6e6352dccb1d156dd322d6c03ff0435..5de6b5f44fd3e4998df94e634e04bd75b16df2e1 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagNodeTranslationTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagNodeTranslationTest.php @@ -4,16 +4,16 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** * Ensures that meta tag values are translated correctly on nodes. * * @group metatag */ -class NodeTranslationTest extends BrowserTestBase { +class MetatagNodeTranslationTest extends BrowserTestBase { - use StringTranslationTrait; + use FieldUiTestTrait; /** * Modules to enable. @@ -79,13 +79,6 @@ protected function setUp(): void { foreach ($this->additionalLangcodes as $langcode) { ConfigurableLanguage::createFromLangcode($langcode)->save(); } - } - - /** - * Tests the metatag value translations. - */ - public function testMetatagValueTranslation() { - $save_label_i18n = 'Save (this translation)'; // Set up a content type. $name = $this->randomMachineName() . ' ' . $this->randomMachineName(); @@ -94,46 +87,56 @@ public function testMetatagValueTranslation() { // Add a metatag field to the content type. $this->drupalGet('admin/structure/types'); - $session = $this->assertSession(); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('admin/structure/types/manage/metatag_node'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'language_configuration[language_alterable]' => TRUE, 'language_configuration[content_translation]' => TRUE, ]; - $this->submitForm($edit, $this->t('Save content type')); - $session->statusCodeEquals(200); - - $this->drupalGet('admin/structure/types/manage/metatag_node/fields/add-field'); - $session->statusCodeEquals(200); - $edit = [ - 'label' => 'Meta tags', - 'field_name' => 'meta_tags', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $session->statusCodeEquals(200); - $this->submitForm([], $this->t('Save field settings')); - $session->statusCodeEquals(200); - $edit = [ - 'translatable' => TRUE, - ]; - $this->submitForm($edit, $this->t('Save settings')); - $session->statusCodeEquals(200); + $this->submitForm($edit, 'Save'); + $this->assertSession()->statusCodeEquals(200); + + $this->fieldUIAddNewField( + 'admin/structure/types/manage/metatag_node', + 'meta_tags', + 'Metatag', + 'metatag', + [], + ['translatable' => TRUE] + ); $this->drupalGet('admin/structure/types/manage/metatag_node/fields/node.metatag_node.field_meta_tags'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); + } + + /** + * Confirm the language translation system isn't accidentally broken. + */ + public function testContentTranslationForm() { + $this->drupalGet('/admin/config/regional/content-language'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextContains('Content language'); + $this->submitForm([], 'Save configuration'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->pageTextContains('Settings successfully updated.'); + } + + /** + * Tests the metatag value translations. + */ + public function testMetatagValueTranslation() { + $save_label_i18n = 'Save (this translation)'; // Set up a node without explicit metatag description. This causes the // global default to be used, which contains a token (node:summary). The // token value should be correctly translated. // Load the node form. $this->drupalGet('node/add/metatag_node'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); // Check the default values are correct. - $session->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); - $session->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); // Create a node. $edit = [ @@ -141,7 +144,7 @@ public function testMetatagValueTranslation() { 'body[0][value]' => 'French summary.', ]; $this->submitForm($edit, 'Save'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $xpath = $this->xpath("//meta[@name='description']"); $this->assertCount(1, $xpath, 'Exactly one description meta tag found.'); @@ -149,20 +152,20 @@ public function testMetatagValueTranslation() { $this->assertEquals($value, 'French summary.'); $this->drupalGet('node/1/translations/add/en/es'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); // Check the default values are there. - $session->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); - $session->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); $edit = [ 'title[0][value]' => 'Node EspaƱol', 'body[0][value]' => 'Spanish summary.', ]; $this->submitForm($edit, $save_label_i18n); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $this->drupalGet('es/node/1'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $xpath = $this->xpath("//meta[@name='description']"); $this->assertCount(1, $xpath, 'Exactly one description meta tag found.'); $value = $xpath[0]->getAttribute('content'); @@ -170,20 +173,20 @@ public function testMetatagValueTranslation() { $this->assertNotEquals($value, 'French summary.'); $this->drupalGet('node/1/edit'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); // Check the default values are there. - $session->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); - $session->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][title]', '[node:title] | [site:name]'); + $this->assertSession()->fieldValueEquals('field_meta_tags[0][basic][description]', '[node:summary]'); // Set explicit values on the description metatag instead using the // defaults. $this->drupalGet('node/1/edit'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'field_meta_tags[0][basic][description]' => 'Overridden French description.', ]; $this->submitForm($edit, $save_label_i18n); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $xpath = $this->xpath("//meta[@name='description']"); $this->assertCount(1, $xpath, 'Exactly one description meta tag found.'); @@ -193,12 +196,12 @@ public function testMetatagValueTranslation() { $this->assertNotEquals($value, 'French summary.'); $this->drupalGet('es/node/1/edit'); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $edit = [ 'field_meta_tags[0][basic][description]' => 'Overridden Spanish description.', ]; $this->submitForm($edit, $save_label_i18n); - $session->statusCodeEquals(200); + $this->assertSession()->statusCodeEquals(200); $xpath = $this->xpath("//meta[@name='description']"); $this->assertCount(1, $xpath, 'Exactly one description meta tag found.'); diff --git a/web/modules/metatag/tests/src/Functional/MetatagStringTest.php b/web/modules/metatag/tests/src/Functional/MetatagStringTest.php index ded5b6c8f7fb10074d6b3ad2c8393b0b020939eb..c25694292af8121370e2c3a1b0a1c3de69bc7455 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagStringTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagStringTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\metatag\Functional; use Drupal\Tests\BrowserTestBase; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** * Ensures that the Metatag field works correctly. @@ -12,7 +12,7 @@ */ class MetatagStringTest extends BrowserTestBase { - use StringTranslationTrait; + use FieldUiTestTrait; /** * Admin user. @@ -69,17 +69,7 @@ protected function setUp(): void { ]); // Add a Metatag field to the content type. - $this->drupalGet('admin/structure/types'); - $this->assertSession()->statusCodeEquals(200); - $this->drupalGet('admin/structure/types/manage/page/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag_field', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $this->submitForm([], $this->t('Save field settings')); + $this->fieldUIAddNewField('admin/structure/types/manage/page', 'metatag_field', 'Metatag', 'metatag'); $this->container->get('entity_field.manager')->clearCachedFieldDefinitions(); } @@ -172,7 +162,7 @@ public function checkConfig($string): void { $this->drupalGet('<front>'); $session->statusCodeEquals(200); - // Again, with xpath the HTML entities will be parsed automagically. + // Again, with xpath the HTML entities will be parsed automatically. $xpath_title = current($this->xpath("//title"))->getText(); $this->assertEquals($xpath_title, $title_original); $this->assertNotEquals($xpath_title, $title_encoded); @@ -185,7 +175,7 @@ public function checkConfig($string): void { $session->responseNotContains('<title>' . $title_original . '</title>'); $session->responseNotContains('<title>' . $title_encodeded . '</title>'); - // Again, with xpath the HTML entities will be parsed automagically. + // Again, with xpath the HTML entities will be parsed automatically. $xpath = $this->xpath("//meta[@name='description']"); $this->assertEquals($xpath[0]->getAttribute('content'), $desc_original); $this->assertNotEquals($xpath[0]->getAttribute('content'), $desc_encoded); @@ -216,7 +206,7 @@ public function checkNode($string): void { 'title' => $title_original, 'description' => $desc_original, ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $session->statusCodeEquals(200); // Set up a node without explicit metatag description. This causes the @@ -236,7 +226,7 @@ public function checkNode($string): void { $this->drupalGet('node/1'); $session->statusCodeEquals(200); - // Again, with xpath the HTML entities will be parsed automagically. + // Again, with xpath the HTML entities will be parsed automatically. $xpath_title = current($this->xpath("//title"))->getText(); $this->assertEquals($xpath_title, $title_original); $this->assertNotEquals($xpath_title, $title_encoded); @@ -246,7 +236,7 @@ public function checkNode($string): void { // because assertRaw() checks the raw HTML, not the parsed strings like // xpath does. $session->responseContains('<title>' . $title_encoded . '</title>'); - // Again, with xpath the HTML entities will be parsed automagically. + // Again, with xpath the HTML entities will be parsed automatically. $xpath = $this->xpath("//meta[@name='description']"); $value = $xpath[0]->getAttribute('content'); $this->assertEquals($value, $desc_original); @@ -284,7 +274,7 @@ public function checkEncodedField($string): void { 'title' => $title_original, 'description' => $desc_original, ]; - $this->submitForm($edit, $this->t('Save')); + $this->submitForm($edit, 'Save'); $session->statusCodeEquals(200); // Set up a node without explicit metatag description. This causes the @@ -304,7 +294,7 @@ public function checkEncodedField($string): void { $this->drupalGet('node/1'); $session->statusCodeEquals(200); - // With xpath the HTML entities will be parsed automagically. + // With xpath the HTML entities will be parsed automatically. $xpath = $this->xpath("//meta[@name='description']"); $value = $xpath[0]->getAttribute('content'); $this->assertEquals($value, $desc_original); diff --git a/web/modules/metatag/tests/src/Functional/MetatagTokenStatus.php b/web/modules/metatag/tests/src/Functional/MetatagTokenStatusTest.php similarity index 94% rename from web/modules/metatag/tests/src/Functional/MetatagTokenStatus.php rename to web/modules/metatag/tests/src/Functional/MetatagTokenStatusTest.php index 4d6a13b7be1e1b0d3180c98b91a09c619caac8a3..067df4d8e76da7bda4ef6289b6982820fa549847 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagTokenStatus.php +++ b/web/modules/metatag/tests/src/Functional/MetatagTokenStatusTest.php @@ -10,7 +10,7 @@ * * @group metatag */ -class MetatagTokenStatus extends BrowserTestBase { +class MetatagTokenStatusTest extends BrowserTestBase { /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/MetatagTokenTest.php b/web/modules/metatag/tests/src/Functional/MetatagTokenTest.php index c03c6d6c61f01f34200dc650af13b81041ed4743..1d9d907b358eae4b34ad61c161f21185f577e8fd 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagTokenTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagTokenTest.php @@ -12,7 +12,7 @@ * * @group metatag */ -class TokenTest extends BrowserTestBase { +class MetatagTokenTest extends BrowserTestBase { use TokenTestTrait; use FieldUiTestTrait; diff --git a/web/modules/metatag/tests/src/Functional/MetatagXssTest.php b/web/modules/metatag/tests/src/Functional/MetatagXssTest.php index f88962d72787c4f03e24515fb9441ded8b7d1b45..fb437c758f239500a71b8ce7491835cd1a50d9c7 100644 --- a/web/modules/metatag/tests/src/Functional/MetatagXssTest.php +++ b/web/modules/metatag/tests/src/Functional/MetatagXssTest.php @@ -2,16 +2,18 @@ namespace Drupal\Tests\metatag\Functional; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\field_ui\Traits\FieldUiTestTrait; /** * Ensures that meta tags do not allow xss vulnerabilities. * * @group metatag */ -class XssTest extends BrowserTestBase { +class MetatagXssTest extends BrowserTestBase { + use FieldUiTestTrait; use StringTranslationTrait; /** @@ -107,15 +109,7 @@ protected function setUp(): void { ]); // Add a metatag field to the content type. - $this->drupalGet('admin/structure/types/manage/metatag_node/fields/add-field'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'label' => 'Metatag', - 'field_name' => 'metatag_field', - 'new_storage_type' => 'metatag', - ]; - $this->submitForm($edit, $this->t('Save and continue')); - $this->submitForm([], $this->t('Save field settings')); + $this->fieldUIAddNewField('admin/structure/types/manage/metatag_node', 'metatag_field', 'Metatag', 'metatag'); } /** diff --git a/web/modules/metatag/tests/src/Functional/NodeJsonOutput.php b/web/modules/metatag/tests/src/Functional/NodeJsonOutputTest.php similarity index 98% rename from web/modules/metatag/tests/src/Functional/NodeJsonOutput.php rename to web/modules/metatag/tests/src/Functional/NodeJsonOutputTest.php index 3aa8f23369f8475a08619e04d3b8a991d36f05ac..29600c82f701c20b5524f8cc90935f4cd1d32c05 100644 --- a/web/modules/metatag/tests/src/Functional/NodeJsonOutput.php +++ b/web/modules/metatag/tests/src/Functional/NodeJsonOutputTest.php @@ -11,7 +11,7 @@ * * @group metatag */ -class NodeJsonOutput extends BrowserTestBase { +class NodeJsonOutputTest extends BrowserTestBase { // Contains helper methods. use MetatagHelperTrait; diff --git a/web/modules/metatag/tests/src/Functional/NodeTranslation.php b/web/modules/metatag/tests/src/Functional/NodeTranslation.php deleted file mode 100644 index bd2207f35e55e02dcd4306a646e8b68999b36afe..0000000000000000000000000000000000000000 --- a/web/modules/metatag/tests/src/Functional/NodeTranslation.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -namespace Drupal\Tests\metatag\Functional; - -use Drupal\Tests\BrowserTestBase; - -/** - * Verify that node translation form works. - * - * @group metatag - */ -class NodeTranslation extends BrowserTestBase { - - // Contains helper methods. - use MetatagHelperTrait; - - /** - * {@inheritdoc} - */ - protected static $modules = [ - // Modules for core functionality. - 'language', - 'node', - 'field_ui', - 'user', - - // Contrib dependencies. - 'token', - - // This module. - 'metatag', - - // The extra module(s) to test. - 'content_translation', - ]; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - // Login. - $this->loginUser1(); - - // Add language. - $this->drupalGet('/admin/config/regional/language/add'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'predefined_langcode' => 'hu', - ]; - $this->submitForm($edit, 'Add language'); - - // Set up a content type. - $this->drupalCreateContentType(['type' => 'article']); - $this->drupalGet('/admin/structure/types/manage/article'); - $this->assertSession()->statusCodeEquals(200); - $edit = [ - 'language_configuration[content_translation]' => TRUE, - ]; - $this->submitForm($edit, 'Save content type'); - } - - /** - * Load the custom route, make sure something is output. - */ - public function testContentTranslationForm() { - $this->drupalGet('/admin/config/regional/content-language'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Content language'); - $this->submitForm([], 'Save configuration'); - $this->assertSession()->statusCodeEquals(200); - $this->assertSession()->pageTextContains('Settings successfully updated.'); - } - -} diff --git a/web/modules/metatag/tests/src/Functional/TagsTestBase.php b/web/modules/metatag/tests/src/Functional/TagsTestBase.php index 12b2d46a1953386a53135f67f62d3eab87d26f5c..83b86282e1e9d81eedd3c84560f48507260b42ec 100644 --- a/web/modules/metatag/tests/src/Functional/TagsTestBase.php +++ b/web/modules/metatag/tests/src/Functional/TagsTestBase.php @@ -4,8 +4,6 @@ use Drupal\Component\Render\FormattableMarkup; use Drupal\Tests\BrowserTestBase; -use Symfony\Component\DependencyInjection\Container; -use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Base class to test all of the meta tags that are in a specific module. @@ -13,7 +11,6 @@ abstract class TagsTestBase extends BrowserTestBase { use MetatagHelperTrait; - use StringTranslationTrait; /** * {@inheritdoc} @@ -73,10 +70,10 @@ public function testTags() { // Create a content type to test with. $this->createContentType(['type' => 'page']); $this->drupalCreateNode([ - 'title' => $this->t('Hello, world!'), + 'title' => 'Hello, world!', 'type' => 'page', ]); - + // Build a list of all tag objects that will be used later on. $tag_manager = \Drupal::service('plugin.manager.metatag.tag'); $all_tags = []; @@ -123,7 +120,10 @@ public function testTags() { dump([$tag_name => $form_field_xpath]); } $xpath = $this->xpath($form_field_xpath); - $this->assertCount(1, $xpath, new FormattableMarkup('One @tag tag form field found using: @xpath', ['@tag' => $tag_name, '@xpath' => $form_field_xpath])); + $this->assertCount(1, $xpath, new FormattableMarkup('One @tag tag form field found using: @xpath', [ + '@tag' => $tag_name, + '@xpath' => $form_field_xpath, + ])); } // Get the key value(s) that will be identified for this tag. Make sure @@ -160,14 +160,20 @@ public function testTags() { dump([$tag_name => $tag_string]); } $xpath = $this->xpath($tag_string); - $this->assertCount(1, $xpath, new FormattableMarkup('One @tag tag found using: @xpath', ['@tag' => $tag_name, '@xpath' => $tag_string])); + $this->assertCount(1, $xpath, new FormattableMarkup('One @tag tag found using: @xpath', [ + '@tag' => $tag_name, + '@xpath' => $tag_string, + ])); } foreach ($tag->getTestOutputValuesXpath($tag_values[$tag_name]) as $output_string) { if ($this->debugMode) { dump([$tag_name => $output_string]); } $xpath = $this->xpath($output_string); - $this->assertCount(1, $xpath, new FormattableMarkup('Tag output for @tag found using: @xpath', ['@tag' => $tag_name, '@xpath' => $output_string])); + $this->assertCount(1, $xpath, new FormattableMarkup('Tag output for @tag found using: @xpath', [ + '@tag' => $tag_name, + '@xpath' => $output_string, + ])); } } continue; diff --git a/web/modules/metatag/tests/src/Functional/Update/TestV2Updates.php b/web/modules/metatag/tests/src/Functional/Update/V2UpdatesTest.php similarity index 99% rename from web/modules/metatag/tests/src/Functional/Update/TestV2Updates.php rename to web/modules/metatag/tests/src/Functional/Update/V2UpdatesTest.php index 598d44d70223942255bce7177b404d5ecd99e737..afe749fc0c548a3813cc91ccda96d29a9de287e5 100644 --- a/web/modules/metatag/tests/src/Functional/Update/TestV2Updates.php +++ b/web/modules/metatag/tests/src/Functional/Update/V2UpdatesTest.php @@ -34,7 +34,7 @@ * * @group metatag */ -class TestV2Updates extends UpdatePathTestBase { +class V2UpdatesTest extends UpdatePathTestBase { /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Functional/WithRedirect.php b/web/modules/metatag/tests/src/Functional/WithRedirect.php deleted file mode 100644 index 37340f0faf8bba0605cf3c9202439a0aea68ca7c..0000000000000000000000000000000000000000 --- a/web/modules/metatag/tests/src/Functional/WithRedirect.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -namespace Drupal\Tests\metatag\Functional; - -/** - * Tests the Metatag administration when Redirect is installed. - * - * @group metatag - */ -class WithRedirect extends MetatagAdminTest { - - /** - * {@inheritdoc} - */ - protected static $modules = [ - 'node', - 'field_ui', - 'test_page_test', - 'token', - 'metatag', - - // @see testAvailableConfigEntities - 'block', - 'block_content', - 'comment', - 'contact', - 'menu_link_content', - 'menu_ui', - 'shortcut', - 'taxonomy', - 'entity_test', - - // The whole point of this test. - 'redirect', - ]; - -} diff --git a/web/modules/metatag/tests/src/FunctionalJavascript/MetatagAvailableTokensTest.php b/web/modules/metatag/tests/src/FunctionalJavascript/MetatagAvailableTokensTest.php index f6c92be1feeeffa2b5a3c8393330e222da4e52f5..9b10b97455b06e264769192203701ff03af2c90b 100644 --- a/web/modules/metatag/tests/src/FunctionalJavascript/MetatagAvailableTokensTest.php +++ b/web/modules/metatag/tests/src/FunctionalJavascript/MetatagAvailableTokensTest.php @@ -10,7 +10,7 @@ * * @group metatag */ -class AvailableTokensTest extends WebDriverTestBase { +class MetatagAvailableTokensTest extends WebDriverTestBase { /** * {@inheritdoc} diff --git a/web/modules/metatag/tests/src/Kernel/MetatagSerializationTest.php b/web/modules/metatag/tests/src/Kernel/MetatagSerializationTest.php index 82ae1eef5603d51672c11cb9d69b3cd82408cc6d..4b65396e02c5fac23058e7922531c35df21fc620 100644 --- a/web/modules/metatag/tests/src/Kernel/MetatagSerializationTest.php +++ b/web/modules/metatag/tests/src/Kernel/MetatagSerializationTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\metatag\Kernel; -use Drupal\field\Entity\FieldStorageConfig; -use Drupal\field\Entity\FieldConfig; use Drupal\entity_test\Entity\EntityTest; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\jsonapi\JsonApiResource\ResourceObject; use Drupal\jsonapi\Normalizer\Value\CacheableNormalization; use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; @@ -24,6 +24,7 @@ class MetatagSerializationTest extends EntityKernelTestBase { protected static $modules = [ // Core modules. 'serialization', + 'file', // Contrib modules. 'token', diff --git a/web/modules/metatag/tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php b/web/modules/metatag/tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php index 8a9aff8fee6d40ef5a482e89e93098b4f2cf73ca..da69c7a4aa0a16e15985324034420ab3c62fb5cf 100644 --- a/web/modules/metatag/tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php +++ b/web/modules/metatag/tests/src/Kernel/Migrate/d6/NodewordsEntitiesTest.php @@ -9,9 +9,9 @@ use Drupal\node\NodeInterface; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\TermInterface; +use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; use Drupal\user\Entity\User; use Drupal\user\UserInterface; -use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; /** * Tests migration of per-entity data from Nodewords-D6. @@ -91,19 +91,19 @@ protected function setUp(): void { $this->installSchema('system', ['sequences']); $this->installEntitySchema('metatag_defaults'); - $this->executeMigrations([ - 'd6_nodewords_field', - 'd6_node_type', - 'd6_taxonomy_vocabulary', - 'd6_nodewords_field', - 'd6_nodewords_field_instance', - 'd6_filter_format', - 'd6_user_role', - 'd6_user', - 'd6_comment_type', - 'd6_field', - 'd6_field_instance', - ]); + // Run each migration to avoid problems. No, it's not clear why. + $this->executeMigrations(['d6_nodewords_field']); + $this->executeMigrations(['d6_node_type']); + $this->executeMigrations(['d6_taxonomy_vocabulary']); + $this->executeMigrations(['d6_nodewords_field']); + $this->executeMigrations(['d6_nodewords_field_instance']); + $this->executeMigrations(['d6_filter_format']); + $this->executeMigrations(['d6_user_role']); + $this->executeMigrations(['d6_user']); + $this->executeMigrations(['d6_comment_type']); + $this->executeMigrations(['d6_field']); + $this->executeMigrations(['d6_field_instance']); + $this->fileMigrationSetup(); $this->executeMigrations([ 'd6_node_settings', @@ -136,7 +136,9 @@ public function testMetatag() { ]; $this->assertSame(Json::encode($expected), $node->field_metatag->value); - $node = node_revision_load(2004); + $node_storage_manager = \Drupal::entityTypeManager() + ->getStorage('node'); + $node = $node_storage_manager->loadRevision(2004); $this->assertInstanceOf(NodeInterface::class, $node); $this->assertTrue($node->hasField('field_metatag')); // This should have the "old revision" keywords value, indicating it is diff --git a/web/modules/metatag/tests/src/Kernel/Migrate/d7/MetatagEntitiesTest.php b/web/modules/metatag/tests/src/Kernel/Migrate/d7/MetatagEntitiesTest.php index a9d91027bea265647fa11fa8f6b6b6e186fdb3ed..b50ada28ba6bf63dfc570edbb66e8a40a4890f02 100644 --- a/web/modules/metatag/tests/src/Kernel/Migrate/d7/MetatagEntitiesTest.php +++ b/web/modules/metatag/tests/src/Kernel/Migrate/d7/MetatagEntitiesTest.php @@ -9,9 +9,9 @@ use Drupal\node\NodeInterface; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\TermInterface; +use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; use Drupal\user\Entity\User; use Drupal\user\UserInterface; -use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase; /** * Tests migration of per-entity data from Metatag-D7. @@ -89,23 +89,22 @@ protected function setUp(): void { $this->installEntitySchema('menu_link_content'); $this->installConfig(static::$modules); $this->installSchema('node', ['node_access']); - $this->installSchema('system', ['sequences']); $this->installEntitySchema('metatag_defaults'); - $this->executeMigrations([ - 'language', - 'd7_metatag_field', - 'd7_node_type', - 'd7_taxonomy_vocabulary', - 'd7_metatag_field_instance', - 'd7_metatag_field_instance_widget_settings', - 'd7_user_role', - 'd7_user', - 'd7_comment_type', - 'd7_field', - 'd7_field_instance', - 'd7_language_content_settings', - ]); + // Run each migration to avoid problems. No, it's not clear why. + $this->executeMigrations(['language']); + $this->executeMigrations(['d7_metatag_field']); + $this->executeMigrations(['d7_node_type']); + $this->executeMigrations(['d7_taxonomy_vocabulary']); + $this->executeMigrations(['d7_metatag_field_instance']); + $this->executeMigrations(['d7_metatag_field_instance_widget_settings']); + $this->executeMigrations(['d7_user_role']); + $this->executeMigrations(['d7_user']); + $this->executeMigrations(['d7_comment_type']); + $this->executeMigrations(['d7_field']); + $this->executeMigrations(['d7_field_instance']); + $this->executeMigrations(['d7_language_content_settings']); + $this->fileMigrationSetup(); $this->executeMigrations([ 'd7_node_complete', @@ -130,7 +129,9 @@ public function testMetatag() { ]; $this->assertSame(Json::encode($expected), $node->field_metatag->value); - $node = node_revision_load(998); + $node_storage_manager = \Drupal::entityTypeManager() + ->getStorage('node'); + $node = $node_storage_manager->loadRevision(998); $this->assertInstanceOf(NodeInterface::class, $node); $this->assertTrue($node->hasField('field_metatag')); // This should have the "old revision" keywords value, indicating it is diff --git a/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d6/NodewordsFieldInstanceTest.php b/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d6/NodewordsFieldInstanceTest.php index 2fdef25e0e27fc018dc32e7679e1617e686170e4..959fd551472b1083afc24a3d0c474aca5e468c52 100644 --- a/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d6/NodewordsFieldInstanceTest.php +++ b/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d6/NodewordsFieldInstanceTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\metatag\Kernel\Plugin\migrate\source\d6; -use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; use Drupal\node\Entity\NodeType; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; /** * Tests Metatag-D6 field instance source plugin. diff --git a/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d7/MetatagFieldInstanceTest.php b/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d7/MetatagFieldInstanceTest.php index 5b56c8e03bdb1feda8a5a129cc6f7cc87133f24c..fcb2a988317fe3905137c6db31507a4178440f14 100644 --- a/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d7/MetatagFieldInstanceTest.php +++ b/web/modules/metatag/tests/src/Kernel/Plugin/migrate/source/d7/MetatagFieldInstanceTest.php @@ -2,10 +2,10 @@ namespace Drupal\Tests\metatag\Kernel\Plugin\migrate\source\d7; -use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; use Drupal\node\Entity\NodeType; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase; /** * Tests Metatag-D7 field instance source plugin. diff --git a/web/modules/metatag/tests/src/Unit/MetaNameBaseTest.php b/web/modules/metatag/tests/src/Unit/MetaNameBaseTest.php index df65716af125c72473eb723770181cec9d94d665..9d94d73c2158315fbc7136f37578cf7e1733415a 100644 --- a/web/modules/metatag/tests/src/Unit/MetaNameBaseTest.php +++ b/web/modules/metatag/tests/src/Unit/MetaNameBaseTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\metatag\Unit; +namespace Drupal\Tests\metatag\Unit; use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase; use Drupal\Tests\UnitTestCase; diff --git a/web/modules/metatag/tests/src/Unit/MetatagTrimmerTest.php b/web/modules/metatag/tests/src/Unit/MetatagTrimmerTest.php index 0c072331bca4e2320a194c42e3685bdb06aa449d..fd4820e4481ce202a1d08802aee46e1e742ff13f 100644 --- a/web/modules/metatag/tests/src/Unit/MetatagTrimmerTest.php +++ b/web/modules/metatag/tests/src/Unit/MetatagTrimmerTest.php @@ -1,6 +1,6 @@ <?php -namespace Drupal\metatag\Unit; +namespace Drupal\Tests\metatag\Unit; use Drupal\metatag\MetatagTrimmer; use Drupal\Tests\UnitTestCase; @@ -45,7 +45,7 @@ public function testTrimBeforeValue() { } /** - * Tests the trimAferValue method. + * Tests the trimAfterValue method. */ public function testTrimAfterValue() { $trimResult1 = $this->metatagTrimmer->trimAfterValue('Test 123', 7);