function LibraryDiscoveryTest::testAssetLibraryDeprecation
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryTest::testAssetLibraryDeprecation()
- 8.9.x core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryTest::testAssetLibraryDeprecation()
- 11.x core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryTest::testAssetLibraryDeprecation()
Tests getting a deprecated library.
File
-
core/
tests/ Drupal/ Tests/ Core/ Asset/ LibraryDiscoveryTest.php, line 107
Class
- LibraryDiscoveryTest
- @coversDefaultClass \Drupal\Core\Asset\LibraryDiscovery @group Asset
Namespace
Drupal\Tests\Core\AssetCode
public function testAssetLibraryDeprecation() : void {
$previous_error_handler = set_error_handler(function ($severity, $message, $file, $line) use (&$previous_error_handler) {
// Convert deprecation error into a catchable exception.
if ($severity === E_USER_DEPRECATED) {
throw new \ErrorException($message, 0, $severity, $file, $line);
}
if ($previous_error_handler) {
return $previous_error_handler($severity, $message, $file, $line);
}
});
try {
$this->libraryDiscovery
->getLibraryByName('test', 'test_3');
$this->fail('No deprecation error triggered.');
} catch (\ErrorException $e) {
$this->assertSame('The "test/test_3" asset library is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the test_2 library instead. See https://www.example.com', $e->getMessage());
}
restore_error_handler();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.