summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal
diff options
context:
space:
mode:
authorLee Rowlands <lee.rowlands@previousnext.com.au>2025-05-01 07:59:47 +1000
committerLee Rowlands <lee.rowlands@previousnext.com.au>2025-05-01 07:59:47 +1000
commit308ad15102479e2a2020d12a46bcf898959f68e1 (patch)
treefac977265393e638bd99ceb10ee6cce625791261 /core/tests/Drupal
parent6810f24aef13523c17d35d753cadb42ac5b9a0fc (diff)
downloaddrupal-11.x.tar.gz
drupal-11.x.zip
Issue #3495943 by nicxvan, berdir, ghost of drupal past, catch, larowlan: Handle module preprocess functions as OOP hooksHEAD11.x
Diffstat (limited to 'core/tests/Drupal')
-rw-r--r--core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php13
-rw-r--r--core/tests/Drupal/Tests/Core/Theme/RegistryTest.php18
2 files changed, 10 insertions, 21 deletions
diff --git a/core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php b/core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php
index 774f1289ccd..58b608248c9 100644
--- a/core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Hook/HookCollectorPassTest.php
@@ -143,19 +143,6 @@ class HookCollectorPassTest extends KernelTestBase {
}
/**
- * Test Hook attribute with named arguments, and class with invoke method.
- */
- public function testHookAttribute(): void {
- $module_installer = $this->container->get('module_installer');
- $this->assertTrue($module_installer->install(['hook_collector_hook_attribute']));
- $this->assertFalse(isset($GLOBALS['hook_named_arguments']));
- $this->assertFalse(isset($GLOBALS['hook_invoke_method']));
- drupal_flush_all_caches();
- $this->assertTrue(isset($GLOBALS['hook_named_arguments']));
- $this->assertTrue(isset($GLOBALS['hook_invoke_method']));
- }
-
- /**
* Tests hook ordering with attributes.
*/
public function testHookFirst(): void {
diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
index f237c09d1ca..862d7e2f65d 100644
--- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
@@ -157,19 +157,21 @@ class RegistryTest extends UnitTestCase {
include_once $this->root . '/core/modules/system/tests/modules/theme_test/theme_test.module';
include_once $this->root . '/core/tests/fixtures/test_stable/test_stable.theme';
$themeTestTheme = new ThemeTestHooks();
- $this->moduleHandler->expects($this->atLeastOnce())
+ $this->moduleHandler->expects($this->exactly(2))
->method('invoke')
->with('theme_test', 'theme')
->willReturn($themeTestTheme->theme(NULL, NULL, NULL, NULL));
- $this->moduleHandler->expects($this->atLeastOnce())
+ $this->moduleHandler->expects($this->atMost(50))
->method('invokeAllWith')
- ->with('theme')
- ->willReturnCallback(function (string $hook, callable $callback) {
- $callback(function () {}, 'theme_test');
- });
- $this->moduleHandler->expects($this->atLeastOnce())
+ // $callback is documented on ModuleHandlerInterface::invokeAllWith().
+ // The first argument expects a callable, but it doesn't matter what it
+ // is, use pi() as a canary in case code changes, and it begins to use it.
+ // The second argument is the module name and for that theme_test is
+ // always correct here.
+ ->willReturnCallback(fn (string $hook, callable $callback) => $callback('pi', 'theme_test'));
+ $this->moduleHandler->expects($this->exactly(2))
->method('getModuleList')
- ->willReturn([]);
+ ->willReturn(['theme_test' => NULL]);
$this->moduleList->expects($this->exactly(2))
->method('getPath')
->with('theme_test')