function HookCollectorPassTest::testProceduralHooksSkippedWhenConfigured

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php \Drupal\KernelTests\Core\Hook\HookCollectorPassTest::testProceduralHooksSkippedWhenConfigured()

Test procedural hooks for a module are skipped when skip is set.

Attributes

#[IgnoreDeprecations]

File

core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php, line 124

Class

HookCollectorPassTest
Tests Drupal\Core\Hook\HookCollectorPass.

Namespace

Drupal\KernelTests\Core\Hook

Code

public function testProceduralHooksSkippedWhenConfigured() : void {
  $this->expectUserDeprecationMessage('Code in hook_collector_on_behalf_procedural.module is deprecated in drupal:11.5.0 and must be converted before drupal:13.0.0. Use classes instead. See https://www.drupal.org/node/3619765');
  $this->expectUserDeprecationMessage('Code in hook_collector_skip_procedural.module is deprecated in drupal:11.5.0 and must be converted before drupal:13.0.0. Use classes instead. See https://www.drupal.org/node/3619765');
  $this->expectUserDeprecationMessage('Code in hook_collector_skip_procedural_attribute.module is deprecated in drupal:11.5.0 and must be converted before drupal:13.0.0. Use classes instead. See https://www.drupal.org/node/3619765');
  $module_installer = $this->container
    ->get('module_installer');
  $this->assertTrue($module_installer->install([
    'hook_collector_skip_procedural',
  ]));
  $this->assertTrue($module_installer->install([
    'hook_collector_on_behalf_procedural',
  ]));
  $this->assertTrue($module_installer->install([
    'hook_collector_skip_procedural_attribute',
  ]));
  $this->assertTrue($module_installer->install([
    'hook_collector_on_behalf',
  ]));
  $this->assertFalse(isset($GLOBALS['skip_procedural_all']));
  $this->assertFalse(isset($GLOBALS['procedural_attribute_skip_has_attribute']));
  $this->assertFalse(isset($GLOBALS['procedural_attribute_skip_after_attribute']));
  $this->assertFalse(isset($GLOBALS['procedural_attribute_skip_find']));
  $this->assertFalse(isset($GLOBALS['skipped_procedural_oop_cache_flush']));
  drupal_flush_all_caches();
  $this->assertFalse(isset($GLOBALS['skip_procedural_all']));
  $this->assertFalse(isset($GLOBALS['procedural_attribute_skip_has_attribute']));
  $this->assertFalse(isset($GLOBALS['procedural_attribute_skip_after_attribute']));
  $this->assertTrue(isset($GLOBALS['procedural_attribute_skip_find']));
  $this->assertTrue(isset($GLOBALS['skipped_procedural_oop_cache_flush']));
  $this->assertFalse($this->container
    ->hasParameter('hook_collector_skip_procedural.skip_procedural_hook_scan'));
}

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