2017 © Pedro Peláez
 

project wp-unit-test-project

A starter project for your WordPress plugin or theme unit tests

image

johnpbloch/wp-unit-test-project

A starter project for your WordPress plugin or theme unit tests

  • Sunday, November 24, 2013
  • by johnpbloch
  • Repository
  • 3 Watchers
  • 18 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

WP Unit Test Project

I created this as an easy way to get a unit test suite started for testing WordPress plugins (and themes, I suppose)., (*1)

Getting Started

To create a new project, you'll need Composer. You can use either a global installation or a local one. These instructions will work for global installations, but if you are using the PHAR in this project, just replace composer with php composer.phar in any commands that use composer., (*2)

To install, simply run the following command:, (*3)

composer create-project johnpbloch/wp-unit-test-project my-project

my-project is the name of the directory in which it will install the package., (*4)

This installs a base package along with all the necessary dependencies. One of these dependencies is PHPUnit itself. You don't have to use the version installed by the package, but I thought it would be a good idea to include it too. This will work no matter where PHPUnit is installed as long as you are able to invoke it., (*5)

To run the tests, simply run PHPUnit:, (*6)

vendor/bin/phpunit

I like to add ./vendor/bin to the front of my environment $PATH so that I can omit the path part of the command:, (*7)

phpunit

If you're using Windows your command will be:, (*8)

vendor\bin\phpunit

Next Steps

After you've installed the package, you'll want to edit composer.json to change the name from johnpbloch/wp-unit-test-project to something more appropriate to your project., (*9)

Now you need to import your project and write some tests for it!, (*10)

Adding your project's code as a dependency in Composer is the recommended way to include it in this package, but using a git submodule or SVN external would also work., (*11)

Adding Tests to your Test Suite

By default, this package is configured to treat any PHP file in the tests directory as a unit test case. If you need to add other PHP files to the repo, either put them in a different directory or use a different file extension (such as .inc)., (*12)

To create a new test, just create a new PHP file in the tests directory. This package comes with a custom TestCase class that extends PHPUnit's core TestCase. You should use the bundled test case when creating your test classes:, (*13)

<?php

use JPB\TestTools\TestCase;

class MyNewTest extends TestCase {

}

Other Resources

The Versions

24/11 2013

0.1.x-dev

0.1.9999999.9999999-dev

A starter project for your WordPress plugin or theme unit tests

  Sources   Download

GPL-2.0+

The Requires

 

24/11 2013

0.1.2

0.1.2.0

A starter project for your WordPress plugin or theme unit tests

  Sources   Download

GPL-2.0+

The Requires

 

24/11 2013

dev-master

9999999-dev

A starter project for your WordPress plugin or theme unit tests

  Sources   Download

GPL-2.0+

The Requires

 

16/11 2013

0.1.1

0.1.1.0

A starter project for your WordPress plugin or theme unit tests

  Sources   Download

GPL-2.0+

The Requires

 

16/11 2013

0.1.0

0.1.0.0

A starter project for your WordPress plugin or theme unit tests

  Sources   Download

GPL-2.0+

The Requires