From 0c5324df3b7afd650f55bc137dadd29d475224e0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 19 Sep 2020 09:25:55 +0000 Subject: [PATCH] Tests: Speed up tests for `wp_allow_comment()` by reusing shared fixtures. Props frank-klein. Fixes #51216. git-svn-id: https://develop.svn.wordpress.org/trunk@49002 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment/wpAllowComment.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/comment/wpAllowComment.php b/tests/phpunit/tests/comment/wpAllowComment.php index 5939675c67..07e66d4f56 100644 --- a/tests/phpunit/tests/comment/wpAllowComment.php +++ b/tests/phpunit/tests/comment/wpAllowComment.php @@ -7,11 +7,9 @@ class Tests_Comment_WpAllowComment extends WP_UnitTestCase { protected static $post_id; protected static $comment_id; - function setUp() { - parent::setUp(); - - self::$post_id = self::factory()->post->create(); - self::$comment_id = self::factory()->comment->create( + public static function wpSetupBeforeClass( $factory ) { + self::$post_id = $factory->post->create(); + self::$comment_id = $factory->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', @@ -25,7 +23,7 @@ class Tests_Comment_WpAllowComment extends WP_UnitTestCase { update_option( 'comment_previously_approved', 0 ); } - function tearDown() { + public static function wpTeardownAfterClass() { wp_delete_post( self::$post_id, true ); wp_delete_comment( self::$comment_id, true );