Download the PHP package sebkay/touchstone without Composer
On this page you can find all versions of the php package sebkay/touchstone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sebkay/touchstone
More information about sebkay/touchstone
Files in sebkay/touchstone
Package touchstone
Short Description A simple framework for running WordPress unit and integration tests.
License MIT
Informations about the package touchstone
Touchstone
A modern wrapper around the official WordPress testsuite. It can be used to run both Unit and Integration tests.
Installation
Run the following command to install Touchstone in your project:
Usage
1.) Setup
Running the setup process downloads and installs both WordPress and the official WordPress test files in your temp directory.
Regular Connection
via a Socket
2.) Creating Tests
All your tests will need to be in the following structure from the root of your project:
All your Unit tests will need to extend the WPTS\Tests\UnitTest
class and all your integrationt tests will need to extend the WPTS\Tests\IntegrationTest
class.
Here's an example Unit test:
Here's an example Integration test:
3.) Running Tests
You can run either all of your tests or a single testsuite with the following commands:
4.) Configuration
You can configure certain things by creating a config.touchstone.php
file in the root of your project.
Directories For Tests
Here's how to set the directories for where your tests are located:
WordPress Plugins
Here's how to load plugins which are loaded before each test.
This means for a plugin like ACF (Advanced Custom Fields) you can use functions like get_field()
in your code and it won't break your tests.
Important: You will need to provide the plugin files. I recommend putting them all in bin/plugins/
in your theme/plugin and the adding that path to your .gitignore
.
WordPress Theme
Here's how to load a theme which is active for each test.
Composer Scripts
You can create Composer scripts so you don't need to memorise the above commands.
To do so add the following to your composer.json
file:
Then you can run the following from the command line:
Troubleshooting
Tests Won't Run
If you ever have problems running your tests, run the setup
command. It's more than likely you've restarted your machine since the last time you ran the tests which deletes the WordPress test files. Re-running the setup process will usually fix the problem.
Why Does This Exist?
The official way of running the WordPress testsuite is horribly complicated and incredibly prone to user error.
Touchstone fixes both of those issues by making the process of creating and running tests easy.
All versions of touchstone with dependencies
phpunit/phpunit Version ^10.2
sebkay/wp-unit-test-stubs Version ^1.0
symfony/console Version ^5.3
guzzlehttp/guzzle Version ^7.3
league/flysystem Version ^2.3
wp-cli/wp-config-transformer Version ^1.2
symfony/process Version ^5.3
php-stubs/wordpress-stubs Version ^5.8
vlucas/phpdotenv Version ^5.5
yoast/phpunit-polyfills Version ^2.0