You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running tests on plugins that modify or alter existing posts, it would be preferable for WPLoader to leave the existing posts alone when it reinstalls. I have a test db for this, but the data is destroyed each time, even with skipInstall active.
For reference, when a post is saved, my plugin fetches data from options, sends that data to an api, and processes the results and saves it to the post meta. It can also do this in bulk using cron and a frontend UI. To test these, I need a set of existing posts, and I need up-to-date options set, as these contain the configs for the plugin. I can create a command that pulls in my existing DB to test to ensure that the data is up to date before the test runs, but want to avoid WP_Loader destroying that data before I run the tests.
Is there a way around this? Or should I not be using WPLoader at all in this case?
the WPLoader module, when used in loadOnly: false mode, will take over the database state, installing and setting up a fresh installation; that is the way it's meant to work to ensure a clean slate for integration tests.
The skipInstall option will still run the installation once, so it's working as intended and, as a consequence, resetting the database.
You can use loadOnly: true in the WPLoader configuration and manage the database state with the WPDb module. The WPDb module can load a database dump that contains the up-to-date data you mention.
The dump configuration parameter of WPLoader might be interesting as well in your case, take a look at that to load a dump after the clean installation completed. Very often it replaces the need to use the WPDb module. In your case you would use the up-to-date dump file you mentioned.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When running tests on plugins that modify or alter existing posts, it would be preferable for WPLoader to leave the existing posts alone when it reinstalls. I have a test db for this, but the data is destroyed each time, even with skipInstall active.
For reference, when a post is saved, my plugin fetches data from options, sends that data to an api, and processes the results and saves it to the post meta. It can also do this in bulk using cron and a frontend UI. To test these, I need a set of existing posts, and I need up-to-date options set, as these contain the configs for the plugin. I can create a command that pulls in my existing DB to test to ensure that the data is up to date before the test runs, but want to avoid WP_Loader destroying that data before I run the tests.
Is there a way around this? Or should I not be using WPLoader at all in this case?
All reactions