Closed lxbdr closed 2 months ago
Adding this to WPLoader
seems to fix the problem:
public function _beforeSuite( array $settings = [] ) {
parent::_beforeSuite( $settings );
Dispatcher::dispatch( Events::SUITE_BEFORE, $this );
}
Thanks @lxbdr for reporting and investigating the issue.
I will try to reproduce the issue next week, debug it and fix it.
I might reach out for help should I not be able to reproduce.
When Codeception\SuiteManager dispatches Events::SUITE_BEFORE the listener is not being called. When checking, the closure is not in the listeners array. I suspect the listener is not correctly added.
Good research, thanks.
The projects "wraps" the Codeception event dispatcher to dispatch and subscribe default and custom events.
Looking at the extensions
section of your configuration file I can see you're not using the EventDispatcherBridge
extension: that might be causing the connection not to happen correctly.
Could you try adding the extension and removing the code from the WPLoader
module class?
Even if it runs correctly this way, the module logic could be improved and fixed.
Thanks for taking a look at this. I have just tested adding the EventDispatcherBridge to extensions and it seems to work. Maybe this could be added to the getting started docs or throw an exception if the extension is not loaded
Thanks @lxbdr for the confirmation of my suspect.
Maybe this could be added to the getting started docs or throw an exception if the extension is not loaded. Yes, if the extensions turns out to be really required. Ideally, and I still have to take the time to make sure it's possible, I would like to avoid making an extension, optional by nature, required.
I will look into this and update this issue accordingly.
@lucatume Hey! We have the same issue and @lxbdr 's suggestion fixes it for us! Is this going to be merged anytime soon?
Version 3.5
If you're opening an issue to report a breakage caused by version
3.5
; please read the migration guide first first!Environment OS: Linux PHP version: 8.2 Installed Codeception version: 5.1.2 Installed wp-browser version: 4.2.5 WordPress version: 6.6 Local development environment: VVV (Vagrant) WordPress structure and management: default
Can you perform the test manually? If applicable, try to walk through the test and execute it manually: can you do it using the browser?
Codeception configuration file
Paste, in a fenced YAML block, the content of your Codeception configuration file; remove any sensitive data!
Suite configuration file Paste, in a fenced YAML block, the content of the suite configuration file; remove any sensitive data!
Describe the bug I would like to run End to End tests on the existing installation without loading a dump. When setting no dump,
populate: false
andcleanup: false
, WordPress is not loaded and not available in the tests. I ran the test usingphp8.2 vendor/bin/codecept run EndToEnd --debug
.I stepped through the code and suspect the following issue: In
WPLoader::_initialize
theloadWordPress
call is hooked intoEvents::SUITE_BEFORE
When
Codeception\SuiteManager
dispatchesEvents::SUITE_BEFORE
the listener is not being called. When checking, the closure is not in the listeners array. I suspect the listener is not correctly added.Output
To Reproduce Steps to reproduce the behavior.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.