3 namespace Drupal\KernelTests\Core\Extension;
5 use Drupal\KernelTests\KernelTestBase;
8 * Test whether deprecated hook invocations trigger errors.
13 * @coversDefaultClass Drupal\Core\Extension\ModuleHandler
15 class ModuleHandlerDeprecatedHookTest extends KernelTestBase {
17 protected static $modules = ['deprecation_test'];
20 * @covers ::invokeDeprecated
21 * @expectedDeprecation The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.
23 public function testInvokeDeprecated() {
24 /* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
25 $module_handler = $this->container->get('module_handler');
29 $module_handler->invokeDeprecated('Use something else.', 'deprecation_test', 'deprecated_hook', [$arg])
34 * @covers ::invokeAllDeprecated
35 * @expectedDeprecation The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.
37 public function testInvokeAllDeprecated() {
38 /* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
39 $module_handler = $this->container->get('module_handler');
43 $module_handler->invokeAllDeprecated('Use something else.', 'deprecated_hook', [$arg])
48 * @covers ::alterDeprecated
49 * @expectedDeprecation The deprecated alter hook hook_deprecated_alter_alter() is implemented in these functions: deprecation_test_deprecated_alter_alter. Alter something else.
51 public function testAlterDeprecated() {
52 /* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
53 $module_handler = $this->container->get('module_handler');
57 $module_handler->alterDeprecated('Alter something else.', 'deprecated_alter', $data, $context1, $context2);
58 $this->assertEqual([$context1, $context2], $data);