From 01e67bb0d0c8aab2797d2d4d95bdbb84f5e61b38 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Sun, 8 Dec 2024 12:01:09 +0100 Subject: [PATCH] fix(test) use fully-qualified namespace name for consts A limit of the serializable-closure library is the fact that class constants will not be translated correctly prepending the fully-qualified namespace name to them. Doing so explicitly removes the need for automated resolution and fill in the gap. --- .../WPBrowser/Module/WPLoaderTest.php | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/unit/lucatume/WPBrowser/Module/WPLoaderTest.php b/tests/unit/lucatume/WPBrowser/Module/WPLoaderTest.php index f879f81d0..c24f327a5 100644 --- a/tests/unit/lucatume/WPBrowser/Module/WPLoaderTest.php +++ b/tests/unit/lucatume/WPBrowser/Module/WPLoaderTest.php @@ -704,11 +704,11 @@ public function should_load_word_press_before_suite_if_load_only_w_config_files( Assert::assertFalse(defined('ABSPATH')); $actions = []; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_LOADONLY, static function () use (&$actions) { - $actions[] = WPLoader::EVENT_BEFORE_LOADONLY; + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_LOADONLY, static function () use (&$actions) { + $actions[] = \lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_LOADONLY; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_LOADONLY, static function () use (&$actions) { - $actions[] = WPLoader::EVENT_AFTER_LOADONLY; + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_LOADONLY, static function () use (&$actions) { + $actions[] = \lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_LOADONLY; }); $wpLoader->_loadWordPress(); @@ -716,8 +716,8 @@ public function should_load_word_press_before_suite_if_load_only_w_config_files( Assert::assertEquals('test_file_002.php', getenv('LOADED_2')); Assert::assertEquals($wpRootDir . '/', ABSPATH); Assert::assertEquals([ - WPLoader::EVENT_BEFORE_LOADONLY, - WPLoader::EVENT_AFTER_LOADONLY, + \lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_LOADONLY, + \lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_LOADONLY, ], $actions); Assert::assertInstanceOf(FactoryStore::class, $wpLoader->factory()); }); @@ -1022,10 +1022,10 @@ public function should_install_and_bootstrap_single_installation(): void $wpLoader = $this->module(); $this->assertInIsolation(static function () use ($wpLoader, $wpRootDir) { $actions = []; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_INSTALL, function () use (&$actions) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_INSTALL, function () use (&$actions) { $actions[] = 'before_install'; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_INSTALL, function () use (&$actions) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_INSTALL, function () use (&$actions) { $actions[] = 'after_install'; }); @@ -1113,10 +1113,10 @@ public function should_install_and_bootstrap_multisite_installation(): void $wpLoader = $this->module(); $installationOutput = $this->assertInIsolation(static function () use ($wpLoader, $wpRootDir) { $actions = []; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_INSTALL, function () use (&$actions) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_INSTALL, function () use (&$actions) { $actions[] = 'before_install'; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_INSTALL, function () use (&$actions) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_INSTALL, function () use (&$actions) { $actions[] = 'after_install'; }); @@ -2581,13 +2581,13 @@ static function () use ($wpLoader, $moduleSplObjectHash) { $beforeInstallCalled = false; $afterInstallCalled = false; $afterBootstrapCalled = false; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { $beforeInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { $afterInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { $afterBootstrapCalled = true; }); @@ -2628,13 +2628,13 @@ static function () use ($moduleSplObjectHash, $wpLoader) { $beforeInstallCalled = false; $afterInstallCalled = false; $afterBootstrapCalled = false; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { $beforeInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { $afterInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { $afterBootstrapCalled = true; }); @@ -2664,13 +2664,13 @@ static function () use ($wpLoader) { $beforeInstallCalled = false; $afterInstallCalled = false; $afterBootstrapCalled = false; - Dispatcher::addListener(WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_BEFORE_INSTALL, function () use (&$beforeInstallCalled) { $beforeInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_INSTALL, function () use (&$afterInstallCalled) { $afterInstallCalled = true; }); - Dispatcher::addListener(WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { + Dispatcher::addListener(\lucatume\WPBrowser\Module\WPLoader::EVENT_AFTER_BOOTSTRAP, function () use (&$afterBootstrapCalled) { $afterBootstrapCalled = true; }); uopz_set_return(Debug::class, 'isEnabled', true);