2017 © Pedro Peláez
 

project wptesttool

The Command Line Interface for creating the Wordpress unit test environment for your plugin.

image

avvertix/wptesttool

The Command Line Interface for creating the Wordpress unit test environment for your plugin.

  • Thursday, January 12, 2017
  • by avvertix
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Wordpress UnitTest tools

This project serves as command line to enable the download of the Wordpress Unittests helper functions and setup the environment for executing your plugin Unit Tests, (*2)

This suite is heavily inspired by the WordPress REST API plugin install-wp-test.sh shell script. That script was a great source to learn how to unittest Wordpress plugins., (*3)

Compatible with Wordpress 4.4.2, (*4)

What?

This toolset, available also in a phar version, downloads the Wordpress release, the Unit Tests includes and assist you during the execution configuration of the tests, (*5)

Usage

step 1, (*6)

In order to configure the required dependencies neeeded to execute a Wordpress based unit test execute:, (*7)

[php] ./bin/wptesttools.phar configure [--db=] [--user=] [--pass=] [--host=] [wp-version]

Available parameters, (*8)

parameter purpose
wp-version The Wordpress version to use for the tests (e.g. 4.4.2). Default value if not specified is latest therefore the latest release will be used

Available options, (*9)

option default value purpose
db wptest The test database name
user wptest The test database username
pass wptest The test database password
host localhost The test database host

step 2, (*10)

Now you can create a stub of the phpunit.xml file and the bootstrap to be loaded when running the unit tests., (*11)

To create the stub files launch, (*12)

[php] ./bin/wptesttools.phar stub [--plugin=plugin.php] [test-folder]
parameter purpose
test-folder The folder where you will place the unit-tests. Default tests
option description
plugin You can specify the file that will be readed by Wordpress to load the plugin

The boostrap will enable the usage of an environment variable called PLUGIN_FILE you can use to specify the main file that will load the plugin in Wordpress., (*13)

Full Commands List

downloadwp Command

Download a Wordpress version and extracts into ./tmp/wordpress/, (*14)

[php] ./bin/wptesttools.phar downloadwp [wp-version]
parameter purpose
wp-version The Wordpress version to use for the tests (e.g. 4.4.2). Default value if not specified is latest therefore the latest release will be used

installwp Command

Download the Wordpress unit test inclusions and the example wp-config to be used when running the tests. The folder used is ./tmp/, (*15)

[php] ./bin/wptesttools.phar installwp [wp-version]
parameter purpose
wp-version The Wordpress version to use for the tests (e.g. 4.4.2). Default value if not specified is latest therefore the latest release will be used

stub Command

Creates the phpunit.xml and a boostrap.php file that define the uni tests configuration and the loader of the dependencies for running the tests., (*16)

[php] ./bin/wptesttools.phar stub [--plugin=plugin.php] [test-folder]
parameter purpose
test-folder The folder where you will place the unit-tests. Default tests
option description
plugin You can specify the file that will be readed by Wordpress to load the plugin
phpunit You can specify the PHPUnit configuration file name (default phpunit.xml)

the phpunit.xml file will be created in the current directory from which the wptesttools binary is executed, while the boostrap.php will be created in the test-folder., (*17)

calling multiple times the stub command will overwrite existing files, (*18)

The Versions

12/01 2017

dev-master

9999999-dev

The Command Line Interface for creating the Wordpress unit test environment for your plugin.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/12 2016

v0.2.0

0.2.0.0

The Command Line Interface for creating the Wordpress unit test environment for your plugin.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/02 2016

v0.1.0

0.1.0.0

The Command Line Interface for creating the Wordpress unit test environment for your plugin.

  Sources   Download

MIT

The Requires

 

The Development Requires