Skip to content
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

Add PHPUnit Testing #98

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
Open

Add PHPUnit Testing #98

wants to merge 10 commits into from

Conversation

jessLundie
Copy link

@jessLundie jessLundie commented Jul 14, 2023

PR in progress

Goal: to add some PHPUnit tests to Safety Net to avoid accidental breaking changes. Related discussion in Slack

Done So Far

  • Basic composer.json with PHPUnit testing and pretty print
  • Testing folders and basic scaffolding files
  • Initial test of get_denylist_array(), which does not require a WP environment

To Do

We need to figure out the best way to simulate testing data for this. Given this plugin mostly operates on the DB, we may need to do this.

I've been looking to WooCommerce Bookings as an example, since it has a fair amount of testing built in. Bookings uses WP_Mock and also possibly a Docker setup to create a local testing environment, then remove it when testing is over.

Then, obviously, write some tests.

Adds PHPUnit & Pretty Printer
Initial test that doesn't require WP environment for testing
wp-phpunit and phpunit-polyfills
This causes composer to check the safety-net repo for packages, which we do not want. We only need the Packagist default on this.
Get basic WP-PHPUnit up and running - need for plugin testing within WP environment
We need to reference our config file to run within our local WP environment
Test now compares actual function-returned array with expected array created directly from assets text file. This test should now cover if we successful retrieved the data, it is correct, and it's structured correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant