dev-master
9999999-devTesting tool for WordPress.
MIT
The Requires
- php >=5.3.0
- phpunit/phpunit 3.7.*
- symfony/yaml ~2.0
wordpress phpunit testing
Testing tool for WordPress.
Testing tool with fixture feature for WordPress plugin development, based on the PHPUnit., (*1)
http://phpunit.de/manual/3.7/en/index.html, (*2)
composer.json
, (*3)
{ "require": { "ackintosh/wptestcase": "dev-master" } }
$ php composer.phar install
$ cd wordpress/wp-content/plugins $ php composer.phar install
, (*4)
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)
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); } }
$ vendor/bin/phpunit
Testing tool for WordPress.
MIT
wordpress phpunit testing