Skip to content

Commit 9c6df62

Browse files
authored
Tests: Make sure test data gets deleted properly (#1543)
* Tests: Make sure users get deleted after creating them * Add missing tear_down_after_class calls * Revert "Tests: Make sure users get deleted after creating them" This reverts commit 27142a4. * Don't delete data manually. `tear_down_after_class` does a better job out of the box.
1 parent ab76874 commit 9c6df62

7 files changed

+0
-80
lines changed

tests/includes/class-test-migration.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,6 @@ public static function set_up_before_class() {
9090
\add_comment_meta( self::$fixtures['comment'], 'activitypub_status', 'federated' );
9191
}
9292

93-
/**
94-
* Tear down the test.
95-
*/
96-
public static function tear_down_after_class() {
97-
// Clean up posts.
98-
foreach ( self::$fixtures['posts'] as $post_id ) {
99-
\wp_delete_post( $post_id, true );
100-
}
101-
102-
// Clean up comment.
103-
if ( isset( self::$fixtures['comment'] ) ) {
104-
\wp_delete_comment( self::$fixtures['comment'], true );
105-
}
106-
}
107-
10893
/**
10994
* Tear down the test.
11095
*/

tests/includes/class-test-move.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ public static function set_up_before_class() {
3131
self::$user_id = self::factory()->user->create( array( 'role' => 'author' ) );
3232
}
3333

34-
/**
35-
* Clean up after tests.
36-
*/
37-
public static function tear_down_after_class() {
38-
wp_delete_user( self::$user_id );
39-
}
40-
4134
/**
4235
* Test the account() method with valid input.
4336
*

tests/includes/handler/class-test-delete.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ public static function set_up_before_class() {
3131
self::$user_id = self::factory()->user->create( array( 'role' => 'author' ) );
3232
}
3333

34-
/**
35-
* Clean up after tests.
36-
*/
37-
public static function tear_down_after_class() {
38-
wp_delete_user( self::$user_id );
39-
40-
parent::tear_down_after_class();
41-
}
42-
4334
/**
4435
* Set up the test.
4536
*/

tests/includes/rest/class-test-actors-inbox-controller.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ public static function set_up_before_class() {
4343
);
4444
}
4545

46-
/**
47-
* Clean up after tests.
48-
*/
49-
public static function tear_down_after_class() {
50-
wp_delete_user( self::$user_id );
51-
}
52-
5346
/**
5447
* Set up the test.
5548
*/

tests/includes/rest/class-test-collections-controller.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,6 @@ public static function set_up_before_class() {
5252
self::factory()->term->add_post_terms( self::$post_id, self::$tag_ids, 'post_tag' );
5353
}
5454

55-
56-
/**
57-
* Tear down.
58-
*/
59-
public static function tear_down_after_class() {
60-
\wp_delete_user( self::$user_id );
61-
62-
foreach ( self::$tag_ids as $tag_id ) {
63-
\wp_delete_term( $tag_id, 'post_tag' );
64-
}
65-
66-
parent::tear_down_after_class();
67-
}
68-
69-
7055
/**
7156
* Test registration of routes.
7257
*

tests/includes/rest/class-test-comments-controller.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,6 @@ public static function set_up_before_class() {
5252
add_comment_meta( self::$comment_ids[0], 'protocol', 'activitypub', true );
5353
}
5454

55-
/**
56-
* Tear down.
57-
*/
58-
public static function tear_down_after_class() {
59-
\wp_delete_user( self::$user_id );
60-
61-
foreach ( self::$comment_ids as $comment_id ) {
62-
\wp_delete_comment( $comment_id );
63-
}
64-
65-
parent::tear_down_after_class();
66-
}
67-
6855
/**
6956
* Set up the test case.
7057
*/

tests/includes/rest/class-test-replies-controller.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,6 @@ public static function set_up_before_class() {
7171
self::$comment_ids = array( $comment_1, $comment_2 );
7272
}
7373

74-
/**
75-
* Tear down.
76-
*/
77-
public static function tear_down_after_class() {
78-
foreach ( self::$comment_ids as $comment_id ) {
79-
\wp_delete_comment( $comment_id, true );
80-
}
81-
82-
\wp_delete_post( self::$post_id, true );
83-
\wp_delete_user( self::$user_id );
84-
85-
parent::tear_down_after_class();
86-
}
87-
8874
/**
8975
* Test registration of routes.
9076
*

0 commit comments

Comments
 (0)