From 91a6444e50976659f79cb6ed9cb485ad775b1973 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 21 Dec 2020 03:33:48 +0000 Subject: [PATCH] Tests: Revert use of shared post fixture in comment template tests. Removes code throwing a fatal in PHP 8. Reverts [49848] from trunk. See #51802. git-svn-id: https://develop.svn.wordpress.org/trunk@49849 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/comment/template.php | 25 +++++------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/tests/phpunit/tests/comment/template.php b/tests/phpunit/tests/comment/template.php index 22283a5c2e..68f98b5c8b 100644 --- a/tests/phpunit/tests/comment/template.php +++ b/tests/phpunit/tests/comment/template.php @@ -3,24 +3,9 @@ * @group comment */ class Tests_Comment_Template extends WP_UnitTestCase { - /** - * Shared post ID. - * - * @var int - */ - public static $post_id; - - /** - * Set up shared fixtures. - * - * @param WP_UnitTest_Factory $factory Unit test factory. - */ - function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { - self::$post_id = self::factory()->post->create(); - } function test_get_comments_number() { - $post_id = self::$post_id; + $post_id = self::factory()->post->create(); $this->assertSame( 0, get_comments_number( 0 ) ); $this->assertSame( '0', get_comments_number( $post_id ) ); @@ -33,7 +18,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { } function test_get_comments_number_without_arg() { - $post_id = self::$post_id; + $post_id = self::factory()->post->create(); $permalink = get_permalink( $post_id ); $this->go_to( $permalink ); @@ -49,7 +34,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { * @ticket 48772 */ function test_get_comments_number_text_with_post_id() { - $post_id = self::$post_id; + $post_id = $this->factory->post->create(); $this->factory->comment->create_post_comments( $post_id, 6 ); $comments_number_text = get_comments_number_text( false, false, false, $post_id ); @@ -68,7 +53,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { * @ticket 13651 */ function test_get_comments_number_text_declension_with_default_args() { - $post_id = self::$post_id; + $post_id = $this->factory->post->create(); $permalink = get_permalink( $post_id ); $this->go_to( $permalink ); @@ -91,7 +76,7 @@ class Tests_Comment_Template extends WP_UnitTestCase { * @dataProvider data_get_comments_number_text_declension */ function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) { - $post_id = self::$post_id; + $post_id = $this->factory->post->create(); $permalink = get_permalink( $post_id ); $this->factory->comment->create_post_comments( $post_id, $number );