lucatume / wp-browser

The easy and reliable way to test WordPress with Codeception. 10 years of proven success.
https://wpbrowser.wptestkit.dev/
MIT License
606 stars 86 forks source link

[SETUP ISSUE] Clean database *after* running tests #478

Closed alexkuc closed 3 years ago

alexkuc commented 3 years ago

Environment OS: Mac High Sierra PHP version: 7.4.2 Installed Codeception version: 4.1.14 Installed wp-browser version: 3.0.2 WordPress version: 5.6 Local development environment: MAMP Pro WordPress structure and management: default

After running acceptance tests, my frontend is white screen (backend works fine).

Investigating further reveals:

+-----------------+----------+-----------+---------+
| name            | status   | update    | version |
+-----------------+----------+-----------+---------+
| twentynineteen  | inactive | available | 1.8     |
| twentyseventeen | inactive | none      | 2.5     |
| twentytwenty    | inactive | none      | 1.6     |
| twentytwentyone | inactive | available | 1.0     |
+-----------------+----------+-----------+---------+

In other words, no theme is selected (executing wp theme activate <theme-name> fixes the issue).

Question: why does this happen and how can I restore default (or desired) theme after running test?

Context: if troubleshooting issue, you go through cycle code edit -> run test -> code edit -> run test; sometimes you need to manually inspect Wordpress and this whitescreen is a bit annoying.

Edit: by acceptance test, I meant I use WPBrowser module (which is commonly part of acceptance test)

Edit: I use WPBrowser and WPDb modules

alexkuc commented 3 years ago

I think I figured out the issue. Out of the box, codecept init wpbrowser generates the following .env.testing (part of it):

TEST_SITE_DB_DSN=
TEST_SITE_DB_HOST=
TEST_SITE_DB_NAME=
TEST_SITE_DB_USER=
TEST_SITE_DB_PASSWORD=
TEST_SITE_TABLE_PREFIX=

However, TEST_SITE_DB_HOST and TEST_SITE_DB_NAME is not used anymore according to docs (only DSN which contains hostname and db name).

Maybe boilerplate generator should be updated to exclude TEST_SITE_DB_HOST and TEST_SITE_DB_NAME?

lucatume commented 3 years ago

@alexkuc Thanks for reporting the issue.

I will look into this and update this issue with news.

alexkuc commented 3 years ago

@lucatume maybe this is not a bug but essentially, after running WPDb, database entries template and stylesheet are missing from wp_options table (this does not affect me really - I am now using a separate database for development and testing - so this can be closed)