Skip to content

Commit

Permalink
fix(test) use fully-qualified namespace name for consts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lucatume committed Dec 8, 2024
1 parent 326d77b commit 01e67bb
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions tests/unit/lucatume/WPBrowser/Module/WPLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,20 +704,20 @@ 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();

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());
});
Expand Down Expand Up @@ -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';
});

Expand Down Expand Up @@ -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';
});

Expand Down Expand Up @@ -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;
});

Expand Down Expand Up @@ -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;
});

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 01e67bb

Please sign in to comment.