Make WordPress Core

Changeset 49848


Ignore:
Timestamp:
12/21/2020 03:15:59 AM (6 years ago)
Author:
peterwilsoncc
Message:

Tests: Use shared post fixture in comment template tests.

See #51802.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/template.php

    r48937 r49848  
    44 */
    55class Tests_Comment_Template extends WP_UnitTestCase {
     6        /**
     7         * Shared post ID.
     8         *
     9         * @var int
     10         */
     11        public static $post_id;
     12
     13        /**
     14         * Set up shared fixtures.
     15         *
     16         * @param WP_UnitTest_Factory $factory Unit test factory.
     17         */
     18        function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     19                self::$post_id = self::factory()->post->create();
     20        }
    621
    722        function test_get_comments_number() {
    8                 $post_id = self::factory()->post->create();
     23                $post_id = self::$post_id;
    924
    1025                $this->assertSame( 0, get_comments_number( 0 ) );
     
    1934
    2035        function test_get_comments_number_without_arg() {
    21                 $post_id   = self::factory()->post->create();
     36                $post_id   = self::$post_id;
    2237                $permalink = get_permalink( $post_id );
    2338                $this->go_to( $permalink );
     
    3550         */
    3651        function test_get_comments_number_text_with_post_id() {
    37                 $post_id = $this->factory->post->create();
     52                $post_id = self::$post_id;
    3853                $this->factory->comment->create_post_comments( $post_id, 6 );
    3954
     
    5469         */
    5570        function test_get_comments_number_text_declension_with_default_args() {
    56                 $post_id   = $this->factory->post->create();
     71                $post_id   = self::$post_id;
    5772                $permalink = get_permalink( $post_id );
    5873                $this->go_to( $permalink );
     
    7792         */
    7893        function test_get_comments_number_text_declension_with_custom_args( $number, $input, $output ) {
    79                 $post_id   = $this->factory->post->create();
     94                $post_id   = self::$post_id;
    8095                $permalink = get_permalink( $post_id );
    8196
Note: See TracChangeset for help on using the changeset viewer.