Build/Test Tools: Document PHP unit test classes.

Props boonebgorges.
Fixes #35494.


git-svn-id: https://develop.svn.wordpress.org/trunk@36854 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
ericlewis 2016-03-05 19:47:41 +00:00
parent 48959ec76e
commit 59c8ba7871
3 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,8 @@
<?php
/**
* An abstract class that serves as a basis for all WordPress object-type factory classes.
*/
abstract class WP_UnitTest_Factory_For_Thing {
var $default_generation_definitions;

View File

@ -1,5 +1,10 @@
<?php
/**
* A factory for making WordPress data with a cross-object type API.
*
* Tests should use this factory to generate test fixtures.
*/
class WP_UnitTest_Factory {
/**

View File

@ -3,6 +3,15 @@
require_once dirname( __FILE__ ) . '/factory.php';
require_once dirname( __FILE__ ) . '/trac.php';
/**
* Defines a basic fixture to run multiple tests.
*
* Resets the state of the WordPress installation before and after every test.
*
* Includes utility functions and assertions useful for testing WordPress.
*
* All WordPress unit tests should inherit from this class.
*/
class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
protected static $forced_tickets = array();
@ -124,6 +133,9 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
$this->expectedDeprecated();
}
/**
* After a test method runs, reset any state in WordPress the test method might have changed.
*/
function tearDown() {
global $wpdb, $wp_query, $wp, $post;
$wpdb->query( 'ROLLBACK' );