Download the PHP package stephenharris/phpunit-require-wordpress-version without Composer
On this page you can find all versions of the php package stephenharris/phpunit-require-wordpress-version. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stephenharris/phpunit-require-wordpress-version
More information about stephenharris/phpunit-require-wordpress-version
Files in stephenharris/phpunit-require-wordpress-version
Package phpunit-require-wordpress-version
Short Description Provides a trait to be used in your PHPUnit test cases to conditionally run tests based on the WordPress version
License MIT
Informations about the package phpunit-require-wordpress-version
@requires WordPress
This package provides a trait (to use in your test cases) so that you can run your phpunit tests for specific WordPress versions:
Then in your tests:
Getting Started
Installation
To install you need:
- PHP 5.4+
- Composer
You can install by running following command in your project folder:
Alternativevely you can directly edit your composer.json by adding:
Setting up your test cases
To use, simply add the use
statement for the provided trait to your test case:
This trait overloads the PHPUnit_Framework_TestCase::checkRequirements()
, if you
already overloading checkRequirements()
in your test case class then you can alias
the method:
If you are using multiple traits with the checkRequirements()
method, then you will
need to resolve the conflicts using aliases:
Examples
Alternative syntax
You use @requires WordPress
with just a version number, and no operator:
which means the test requires WordPress 4.2.0 or higher to run, and is otherwise skipped. Or you can specify an operator. E.g:
which means the test requires a WordPress version strictly before 4.2.0.
The various operators supported are listed below. Also note, that you do not need to include the patch version number if it is 0.
-
WordPress greater than or equal to 4.4.0
- WordPress 4.4
- WordPress 4.4.0
- WordPress >= 4.4.0
- WordPress ge 4.4.0
-
WordPress greater than 4.4.0
- WordPress > 4.4
- WordPress > 4.4.0
- WordPress gt 4.4.0
-
WordPress equal to 4.4.0
- WordPress == 4.4
- WordPress == 4.4.0
- WordPress = 4.4.0
- WordPress eq 4.4.0
-
WordPress not equal to 4.4.0
- WordPress != 4.4
- WordPress != 4.4.0
- WordPress ne 4.4.0
- WordPress <> 4.4.0
-
WordPress less than 4.4.0
- WordPress < 4.4
- WordPress < 4.4.0
- WordPress lt 4.4.0
- WordPress less than or equal to 4.4.0
- WordPress <= 4.4
- WordPress <= 4.4.0
- WordPress le 4.4.0
License
This package is open source and released under MIT license. See LICENSE file for more info.
Questions? Problems?
Please open an issue at https://github.com/stephenharris/phpunit-require-wordpress-version/issues