function DeprecatedAssetsTest::testDeprecatedLibraries

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php \Drupal\KernelTests\Core\Asset\DeprecatedAssetsTest::testDeprecatedLibraries()

Confirms the status and definition contents of deprecated libraries.

@dataProvider deprecatedLibrariesProvider

Parameters

string $extension: The name of the extension that registered a library.

string $name: The name of a registered library to retrieve.

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.

File

core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php, line 31

Class

DeprecatedAssetsTest
Checks the status and definition contents of deprecated libraries.

Namespace

Drupal\KernelTests\Core\Asset

Code

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)));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.