2017 © Pedro Peláez
 

library wptestcase

Testing tool for WordPress.

image

ackintosh/wptestcase

Testing tool for WordPress.

  • Saturday, July 27, 2013
  • by ackintosh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WPTestCase

Testing tool with fixture feature for WordPress plugin development, based on the PHPUnit., (*1)

http://phpunit.de/manual/3.7/en/index.html, (*2)

Installation

composer.json, (*3)

{
    "require": {
        "ackintosh/wptestcase": "dev-master"
    }
}
$ php composer.phar install

Usage

  • Install this tool.
$ cd wordpress/wp-content/plugins
$ php composer.phar install
  • Set up tables for testing that was changed to 'wptest_' a prefix.

Set up tables, (*4)

  • Prepare the fixture file written in YAML.

post_fixture.yml, (*5)

- 
  post_title: Test post title 1
  post_content: Test post content 1
  post_status: publish
- 
  post_title: Test post title 2
  post_content: Test post content 2
  post_status: publish

Available parameters are the same as 'wp_insert_post' function., (*6)

Function Reference/wp insert post, (*7)

  • Write test code.
class SamplePluginTest extends Ackintosh\WPTestCase
{

    // The table prefix for testing can be changed.
    // protected $test_prefix = 'wptest_';

    public function test_insert_post()
    {
        // Loading data.
        $this->setPostFixture(__DIR__ . '/post_fixture.yml');

        // We can get the post data that inserted by the fixture function.
        $posts = get_posts();

        // Can use all features in PHPUnit.
        $this->assertEquals($expect, $result);
    }
}
  • Run the tests.
$ vendor/bin/phpunit

Requirements

  • PHP 5.3 or greater

The Versions

27/07 2013

dev-master

9999999-dev

Testing tool for WordPress.

  Sources   Download

MIT

The Requires

 

wordpress phpunit testing