-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SETUP ISSUE] Teardown error — $wpdb is null #716
Comments
Thanks @Genyus for taking the time to open an issue and complete the report. |
Hi @Genyus, I'm working on this and found some issues with Bedrock + default setup. Did you choose
I've pushed what fixes I've applied so far on the
I could run the Can you run the I'm using a setup similar to yours, with Lando to serve the Bedrock installation. |
I tried to choose To eliminate any conflicts caused by existing project configuration, I created a completely fresh Bedrock + Lando install, installed WPBrowser from your new branch and tried again. After resolving a few local issues (e.g. not having Chrome installed), I was able to complete the setup and get the same results as you — Integration suite passed, EndToEnd failed. With a working instance available, I compared my previous setup to see what was different, but couldn't find anything significant. I disabled all my tests and copied in the sample one, which worked fine, so I restored mine one at a time until I found the culprit — turns out that I hadn't converted it from a Codeception unit test to a WPBrowser test case. 🤦🏾♂️ With that resolved, I then had a dig around the E2E test suite to see if I could figure out why that wasn't working and eventually discovered the two-fold cause:
SERVER_ROOT_DIR=web
WORDPRESS_ROOT_DIR=${SERVER_ROOT_DIR}/wp I then updated the docroot: '%SERVER_ROOT_DIR%' And finally, I modified the adminPath: '/wp/wp-admin'
// Handle WPBrowser test configuration
if (getenv('WORDPRESS_URL')) {
// Reset default URLs
Config::define('WP_HOME', getenv('WORDPRESS_URL'));
Config::define('WP_SITEURL', Config::get('WP_HOME') . substr(env('WP_SITEURL'), strlen(env('WP_HOME')))); // Retain any appended path in WP_SITEURL, e.g. '/wp'
} With these changes in place, all tests now pass successfully 🥳 |
@Genyus thanks for your feedback, I've built on it and, after a bit of iteration, removed the steps that would require modification of the Here is the result of the setup on a clean Bedrock installation I will merge #718, and the transpiled #717, when all tests pass. |
Thanks for implementing such a swift and comprehensive fix, much appreciated 🙏🏾 |
Applies Bedrock compatibility fixes Resolves lucatume/wp-browser#716
Applies Bedrock compatibility fixes Resolves lucatume/wp-browser#716
Environment
OS: macOS 14.2
PHP version: 8.2
Installed Codeception version: 5.1.2
Installed wp-browser version: 4.1.6
WordPress version: 6.5
Local development environment: Lando
WordPress structure and management: Bedrock
Did you use the
codecept init wpbrowser
command?Yes
Did you take a look at Codeception and wp-browser documentation?
Yes
Codeception configuration file
Suite configuration file
If you're encountering an issue with a specific suite, please provide its configuration file.
Test environment file
Describe the issue you're encountering
This is my first time using WPBrowser and after a bit of trial and error due to my Bedrock setup, I've been able to get it running my initial tests. However, an error gets thrown during teardown where it attempts to clear the database, but the
$wpdb
object is null. I've configured the test database to use SQLite and the db appears to be correctly created and populated, but the teardown method is unable to access the corresponding object. My assumption was that it would pick up the database defined by the WPLoader module, but clearly I've misconfigured something, somewhere.I've included the output of a test run with
--debug
enabled below,Output
To Reproduce
codecept generate:wpunit Integration "Acme\User"
codecept run Integration
The text was updated successfully, but these errors were encountered: