mirror of
git://develop.git.wordpress.org/
synced 2025-03-13 16:39:48 +01:00
Tests: Use shared post fixture in comment template tests.
This reinstates [49848], previously reverted in [49849], with the addition of `static` keyword for the `wpSetUpBeforeClass()` method, allowing the tests to pass on PHP 8. Props peterwilsoncc. See #51802. git-svn-id: https://develop.svn.wordpress.org/trunk@49863 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7ef5a65f44
commit
96555f949a
@ -3,9 +3,24 @@
|
||||
* @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.
|
||||
*/
|
||||
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
|
||||
self::$post_id = self::factory()->post->create();
|
||||
}
|
||||
|
||||
function test_get_comments_number() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$post_id = self::$post_id;
|
||||
|
||||
$this->assertSame( 0, get_comments_number( 0 ) );
|
||||
$this->assertSame( '0', get_comments_number( $post_id ) );
|
||||
@ -18,7 +33,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_get_comments_number_without_arg() {
|
||||
$post_id = self::factory()->post->create();
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to( $permalink );
|
||||
|
||||
@ -34,7 +49,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
* @ticket 48772
|
||||
*/
|
||||
function test_get_comments_number_text_with_post_id() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$post_id;
|
||||
$this->factory->comment->create_post_comments( $post_id, 6 );
|
||||
|
||||
$comments_number_text = get_comments_number_text( false, false, false, $post_id );
|
||||
@ -53,7 +68,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
|
||||
* @ticket 13651
|
||||
*/
|
||||
function test_get_comments_number_text_declension_with_default_args() {
|
||||
$post_id = $this->factory->post->create();
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
$this->go_to( $permalink );
|
||||
|
||||
@ -76,7 +91,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 = $this->factory->post->create();
|
||||
$post_id = self::$post_id;
|
||||
$permalink = get_permalink( $post_id );
|
||||
|
||||
$this->factory->comment->create_post_comments( $post_id, $number );
|
||||
|
Loading…
x
Reference in New Issue
Block a user