ackintosh / wptestcase
This package is abandoned and no longer maintained.
No replacement package was suggested.
Testing tool for WordPress.
dev-master
2013-07-27 13:29 UTC
Requires
- php: >=5.3.0
- phpunit/phpunit: 3.7.*
- symfony/yaml: ~2.0
This package is auto-updated.
Last update: 2022-04-16 04:48:27 UTC
README
#WPTestCase
Testing tool with fixture feature for WordPress plugin development, based on the PHPUnit.
http://phpunit.de/manual/3.7/en/index.html
##Installation
composer.json
{
"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.
- Prepare the fixture file written in YAML.
post_fixture.yml
- 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.
Function Reference/wp insert post
- 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