https://github.com/joshcanhelp/wp-test-plugin
WordPress plugin to describe a running test test suite
https://github.com/joshcanhelp/wp-test-plugin
Last synced: 5 months ago
JSON representation
WordPress plugin to describe a running test test suite
- Host: GitHub
- URL: https://github.com/joshcanhelp/wp-test-plugin
- Owner: joshcanhelp
- License: gpl-3.0
- Created: 2020-08-29T17:55:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-03T16:40:25.000Z (5 months ago)
- Last Synced: 2025-02-07T11:58:47.891Z (5 months ago)
- Language: PHP
- Size: 56.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WordPress Test Plugin
This is an installable sample plugin for showing running tests in a WordPress environment. See [the introduction post](https://www.joshcanhelp.com/wordpress-unit-testing-techniques/) for more details about how this is used.
## Getting Started
The purpose of this plugin is to show example tests against functional code. I used the [WP-CLI unit test helper](https://make.wordpress.org/cli/handbook/misc/plugin-unit-tests/) to generate what I needed and made changes from there.
In order to run tests, you'll need a locally running database server (I used Brew for this following [this guide](https://getgrav.org/blog/macos-catalina-apache-mysql-vhost-apc)). Using WP-CLI link above, look for the command `bin/install-wp-tests.sh` and follow the instructions to get the environment up and running. I **always** have issues getting this running from the start so give yourself some time (and grace) if it's your first time through the process!
Once that's working, the rest is Composer:
```bash
$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Installing lots of stuff ...$ composer test
> "vendor/bin/phpunit"....................... 23 / 23 (100%)
Time: 1.02 seconds, Memory: 28.00 MB
OK (23 tests, 74 assertions)
```