From b6133d88abb961aa460a60a57a921de4f3a6243c Mon Sep 17 00:00:00 2001 From: xjm <xjm@65776.no-reply.drupal.org> Date: Thu, 5 Jan 2023 13:26:08 -0600 Subject: [PATCH] Issue #3296086 by Spokje, catch, smustgrave, xjm: Deprecate/remove js-cookie dependency --- core/core.libraries.yml | 1 + .../Core/Asset/DeprecatedAssetsTest.php | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php diff --git a/core/core.libraries.yml b/core/core.libraries.yml index 26c0654c9f64..1a188ec2f1d7 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -911,3 +911,4 @@ js-cookie: gpl-compatible: true js: assets/vendor/js-cookie/js.cookie.min.js: {} + deprecated: The %library_id% asset library is deprecated in Drupal 10.1.0 and will be removed in Drupal 11.0.0. There is no replacement. See https://www.drupal.org/node/3322720 diff --git a/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php b/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php new file mode 100644 index 000000000000..1225d776ac2d --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php @@ -0,0 +1,71 @@ +<?php + +namespace Drupal\KernelTests\Core\Asset; + +use Drupal\KernelTests\KernelTestBase; + +/** + * Checks the status and definition contents of deprecated libraries. + * + * @group Asset + * @group legacy + */ +class DeprecatedAssetsTest extends KernelTestBase { + + /** + * Confirms the status and definition contents of deprecated libraries. + * + * @param string $extension + * The name of the extension that registered a library. + * @param string $name + * The name of a registered library to retrieve. + * @param string $deprecation_suffix + * The part of the deprecation message after the extension/name. + * @param string $expected_hashed_library_definition + * The expected MD5 hash of the library. + * + * @dataProvider deprecatedLibrariesProvider + */ + public function testDeprecatedLibraries(string $extension, string $name, string $deprecation_suffix, string $expected_hashed_library_definition): void { + /** @var \Drupal\Core\Asset\LibraryDiscoveryInterface $library_discovery */ + $library_discovery = $this->container->get('library.discovery'); + + // DrupalCI uses a precision of 100 in certain environments which breaks + // this test. + ini_set('serialize_precision', -1); + + $this->expectDeprecation("The $extension/$name " . $deprecation_suffix); + $library_definition = $library_discovery->getLibraryByName($extension, $name); + $this->assertEquals($expected_hashed_library_definition, md5(serialize($library_definition))); + } + + /** + * The data provider for testDeprecatedLibraries. + * + * Returns an array in the form of + * @code + * [ + * (string) description => [ + * (string) extension - The name of the extension that registered a library, usually 'core' + * (string) name - The name of a registered library + * (string) deprecation_suffix - The part of the deprecation message after the extension/name + * (string) expected_hashed_library_definition - The expected MD5 hash of the library + * ] + * ] + * @endcode + * + * @return array + * See description above. + */ + public function deprecatedLibrariesProvider(): array { + return [ + 'Tests deprecation of library core/js-cookie' => [ + 'core', + 'js-cookie', + 'asset library is deprecated in Drupal 10.1.0 and will be removed in Drupal 11.0.0. There is no replacement. See https://www.drupal.org/node/3322720', + '07ce73936a26710db875a3e9ee70cd6e', + ], + ]; + } + +} -- GitLab