Add initial PHPUnit test infrastructure.#60
Conversation
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
The wp-env config runs PHP 7.4, and there are various features (arrow functions, etc.) that are already in the codebase. PHP 7.2.24 is too early for some of these. Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
WordPress 5.4 is the version after initial PHP 7.4 support was added. Note: This is likely to be bumped even higher. Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
|
Does the release action need to exclude tests or is that handled somehow? |
|
I think we're okay - The tests workflow is set to run on Was there something you saw in the release action that raised the concern? |
|
@costdev ah, I was specifically talking about the files like |
|
@joehoyle You know, I had a feeling I had misinterpreted 😂, thanks for clarifying! Yeah I'll need to update the |
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
|
confirmed this worked setting up on a local VVV instance |
|
|
Just need someone to do a wp-env test to confirm. |
|
I have tested in wp-env and it seems to be working. |
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
This adds an initial setup for PHPUnit tests.
Changes
./bin/install-wp-tests.sh./tests/phpunit/bootstrap.php./wp-tests-config-sample.php./phpunit.xml.distand./tests/phpunit/multisite.xmlrespectively./tests/phpunit/tests/SampleTest.phpAdditional changes to the plugin
Instructions
Setting up the dev environment
Option 1: wp-env
npm inpm run env startnpm run test:php:install-depswp-tests-config-sample.phptowp-tests-config.php.Option 2: Local web server and MySQL database:
composer installmysql -u<username> -p->CREATE DATABASE <database_name>;->exit;wp-tests-config-sample.phptowp-tests-config.php.DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTinwp-tests-config.phpmatch your setup../bin/install-wp-tests.shwith the appropriate credentials.Running PHPUnit tests
Single Site
If you're not using wp-env, you can just run
composer run test.Multisite
If you're not using wp-env, you can just run
composer run test:multisite.Running PHPUnit tests with line coverage
First, start the environment with xDebug:
If you're not using wp-env, make sure the xDebug PHP module is installed and enabled.
Single Site
If you're not using wp-env, you can just run
composer run coverage:single.A coverage report will be available at
/tests/phpunit/coverage/html/single-site.Multisite
If you're not using wp-env, you can just run
composer run coverage:multisite.A coverage report will be available at
/tests/phpunit/coverage/html/multisite.Single Site and Multisite
If you're not using wp-env, you can just run
composer run coverage:full.A merged coverage report will be available at
/tests/phpunit/coverage/html/full.This PR only adds a sample test for guidance, which will be ignored when running the test suite. You'll know the above works if PHPUnit runs and "No tests executed!" is displayed.
Fixes #59