Loading core/lib/Drupal/Core/Hook/HookCollectorPass.php +3 −3 Original line number Diff line number Diff line Loading @@ -169,9 +169,9 @@ protected function collectModuleHookImplementations($dir, $module, $module_preg) $extension = $fileinfo->getExtension(); $filename = $fileinfo->getPathname(); if ($extension === 'module' && !$iterator->getDepth()) { // There is an expectation for all modules to be loaded. However, // .module files are not supposed to be in subdirectories. if (($extension === 'module' || $extension === 'profile') && !$iterator->getDepth()) { // There is an expectation for all modules and profiles to be loaded. // .module and .profile files are not supposed to be in subdirectories. include_once $filename; } if ($extension === 'php') { Loading core/profiles/tests/testing_hooks/src/Hook/TestingHooksProfile.php 0 → 100644 +23 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\testing_hooks\Hook; use Drupal\Core\Hook\Attribute\Hook; /** * Hook implementation on behalf of another module. */ class TestingHooksProfile { /** * Implements hook_module_preinstall(). */ #[Hook('cache_flush')] public function flush(): void { // Set a global value we can check in test code. $GLOBALS['profile_oop'] = 'profile_oop'; } } core/profiles/tests/testing_hooks/testing_hooks.info.yml 0 → 100644 +10 −0 Original line number Diff line number Diff line name: Testing Hooks in profile type: profile description: 'Minimal profile for running tests. Includes absolutely required modules only.' version: VERSION hidden: true install: # Enable page_cache and dynamic_page_cache in testing, to ensure that as many # tests as possible run with them enabled. - drupal:page_cache - dynamic_page_cache core/profiles/tests/testing_hooks/testing_hooks.profile 0 → 100644 +18 −0 Original line number Diff line number Diff line <?php /** * @file * Implement hooks. */ declare(strict_types=1); /** * This implements cache_flush. * * We do not have implements so this does not get converted. */ function testing_hooks_cache_flush(): void { // Set a global value we can check in test code. $GLOBALS['profile_procedural'] = 'profile_procedural'; } core/tests/Drupal/FunctionalTests/Installer/TestingProfileHooks.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\FunctionalTests\Installer; use Drupal\Tests\BrowserTestBase; /** * Tests installing the Testing profile with update notifications on. * * @group Installer */ class TestingProfileHooks extends BrowserTestBase { /** * {@inheritdoc} */ protected $profile = 'testing_hooks'; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Test hooks are picked up. */ public function testHookPickup(): void { $this->assertFalse(isset($GLOBALS['profile_procedural'])); $this->assertFalse(isset($GLOBALS['profile_oop'])); drupal_flush_all_caches(); $this->assertTrue(isset($GLOBALS['profile_procedural'])); $this->assertTrue(isset($GLOBALS['profile_oop'])); } } Loading
core/lib/Drupal/Core/Hook/HookCollectorPass.php +3 −3 Original line number Diff line number Diff line Loading @@ -169,9 +169,9 @@ protected function collectModuleHookImplementations($dir, $module, $module_preg) $extension = $fileinfo->getExtension(); $filename = $fileinfo->getPathname(); if ($extension === 'module' && !$iterator->getDepth()) { // There is an expectation for all modules to be loaded. However, // .module files are not supposed to be in subdirectories. if (($extension === 'module' || $extension === 'profile') && !$iterator->getDepth()) { // There is an expectation for all modules and profiles to be loaded. // .module and .profile files are not supposed to be in subdirectories. include_once $filename; } if ($extension === 'php') { Loading
core/profiles/tests/testing_hooks/src/Hook/TestingHooksProfile.php 0 → 100644 +23 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\testing_hooks\Hook; use Drupal\Core\Hook\Attribute\Hook; /** * Hook implementation on behalf of another module. */ class TestingHooksProfile { /** * Implements hook_module_preinstall(). */ #[Hook('cache_flush')] public function flush(): void { // Set a global value we can check in test code. $GLOBALS['profile_oop'] = 'profile_oop'; } }
core/profiles/tests/testing_hooks/testing_hooks.info.yml 0 → 100644 +10 −0 Original line number Diff line number Diff line name: Testing Hooks in profile type: profile description: 'Minimal profile for running tests. Includes absolutely required modules only.' version: VERSION hidden: true install: # Enable page_cache and dynamic_page_cache in testing, to ensure that as many # tests as possible run with them enabled. - drupal:page_cache - dynamic_page_cache
core/profiles/tests/testing_hooks/testing_hooks.profile 0 → 100644 +18 −0 Original line number Diff line number Diff line <?php /** * @file * Implement hooks. */ declare(strict_types=1); /** * This implements cache_flush. * * We do not have implements so this does not get converted. */ function testing_hooks_cache_flush(): void { // Set a global value we can check in test code. $GLOBALS['profile_procedural'] = 'profile_procedural'; }
core/tests/Drupal/FunctionalTests/Installer/TestingProfileHooks.php 0 → 100644 +37 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\FunctionalTests\Installer; use Drupal\Tests\BrowserTestBase; /** * Tests installing the Testing profile with update notifications on. * * @group Installer */ class TestingProfileHooks extends BrowserTestBase { /** * {@inheritdoc} */ protected $profile = 'testing_hooks'; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Test hooks are picked up. */ public function testHookPickup(): void { $this->assertFalse(isset($GLOBALS['profile_procedural'])); $this->assertFalse(isset($GLOBALS['profile_oop'])); drupal_flush_all_caches(); $this->assertTrue(isset($GLOBALS['profile_procedural'])); $this->assertTrue(isset($GLOBALS['profile_oop'])); } }