Unit Tests:

* Automatically delete objects that we were created during `wpSetUpBeforeClass` - posts, comments, terms (except 1), and user (except 1)
* The amount of leftover data between tests was breathtaking - use the new function: `_delete_all_data()`
* Commit database transactions for all `TestCase`s, not just those that implement `wpSetUpBeforeClass` and `wpTearDownAfterClass`
* The tests run 10-20 seconds faster now

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38398 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2016-08-27 08:35:16 +00:00
parent f0af25bd80
commit 02319efa71
51 changed files with 60 additions and 371 deletions
@@ -41,17 +41,6 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
) );
}
/**
* Delete the post and comments for the tests.
*/
public static function wpTearDownAfterClass() {
foreach ( self::$comment_ids as $comment_id ) {
wp_delete_comment( $comment_id, true );
}
wp_delete_post( self::$post_id, true );
}
/**
* Verify that both the comment date and author must match for a comment to exist.
*/
@@ -6,10 +6,6 @@
*/
class Tests_Admin_includesFile extends WP_UnitTestCase {
function setUp() {
parent::setUp();
}
/**
* @ticket 20449
*/
@@ -4,10 +4,10 @@
* @group admin
*/
class Tests_Admin_includesListTable extends WP_UnitTestCase {
protected static $top;
protected static $children;
protected static $grandchildren;
protected static $post_ids;
protected static $top = array();
protected static $children = array();
protected static $grandchildren = array();
protected static $post_ids = array();
function setUp() {
parent::setUp();
@@ -64,12 +64,6 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
}
}
public static function wpTearDownAfterClass() {
foreach ( self::$post_ids as $post_id ) {
wp_delete_post( $post_id, true );
}
}
/**
* @ticket 15459
*/
@@ -22,14 +22,6 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
self::$post_id = $factory->post->create();
}
public static function wpTearDownAfterClass() {
foreach ( self::$user_ids as $id ) {
self::delete_user( $id );
}
wp_delete_post( self::$post_id, true );
}
function test__wp_translate_postdata_cap_checks_contributor() {
wp_set_current_user( self::$contributor_id );