You are here

public function ModuleHandlerDeprecatedHookTest::testAlterDeprecated in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerDeprecatedHookTest.php \Drupal\KernelTests\Core\Extension\ModuleHandlerDeprecatedHookTest::testAlterDeprecated()
  2. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerDeprecatedHookTest.php \Drupal\KernelTests\Core\Extension\ModuleHandlerDeprecatedHookTest::testAlterDeprecated()

@covers ::alterDeprecated

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleHandlerDeprecatedHookTest.php, line 50

Class

ModuleHandlerDeprecatedHookTest
Test whether deprecated hook invocations trigger errors.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testAlterDeprecated() {
  $this
    ->expectDeprecation('The deprecated alter hook hook_deprecated_alter_alter() is implemented in these functions: deprecation_test_deprecated_alter_alter. Alter something else.');

  /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
  $module_handler = $this->container
    ->get('module_handler');
  $data = [];
  $context1 = 'test1';
  $context2 = 'test2';
  $module_handler
    ->alterDeprecated('Alter something else.', 'deprecated_alter', $data, $context1, $context2);
  $this
    ->assertEquals([
    $context1,
    $context2,
  ], $data);
}