WordPress.org

Make WordPress Core

Ticket #30017: get-next-comments-link.patch

File get-next-comments-link.patch, 1.6 KB (added by Frank Klein, 3 years ago)
  • tests/phpunit/tests/link/getNextCommentsLink.php

    diff --git tests/phpunit/tests/link/getNextCommentsLink.php tests/phpunit/tests/link/getNextCommentsLink.php
    index 204b2057ff..8e8b499854 100644
     
    66 * @covers ::get_next_comments_link
    77 */
    88class Tests_Link_GetNextCommentsLink extends WP_UnitTestCase {
     9        /**
     10         * Post permalink.
     11         *
     12         * @var string
     13         */
     14        public static $post_permalink;
    915
    10         public function test_page_should_respect_value_of_cpage_query_var() {
    11                 $p = self::factory()->post->create();
    12                 $this->go_to( get_permalink( $p ) );
     16        public static function wpSetUpBeforeClass( $factory ) {
     17                self::$post_permalink = get_permalink( $factory->post->create() );
     18        }
    1319
    14                 $cpage = get_query_var( 'cpage' );
     20        public function test_page_should_respect_value_of_cpage_query_var() {
     21                $this->go_to( self::$post_permalink );
    1522                set_query_var( 'cpage', 3 );
    1623
    17                 $link = get_next_comments_link( 'Next', 5 );
    18 
    19                 $this->assertContains( 'cpage=4', $link );
    20 
    21                 set_query_var( 'cpage', $cpage );
     24                $this->assertContains( 'cpage=4', get_next_comments_link( 'Next', 5 ) );
    2225        }
    2326
    2427        /**
    2528         * @ticket 20319
    2629         */
    2730        public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
    28                 $p = self::factory()->post->create();
    29                 $this->go_to( get_permalink( $p ) );
    30 
    31                 $cpage = get_query_var( 'cpage' );
     31                $this->go_to( self::$post_permalink );
    3232                set_query_var( 'cpage', '' );
    3333
    34                 $link = get_next_comments_link( 'Next', 5 );
    35 
    36                 $this->assertContains( 'cpage=2', $link );
    37 
    38                 set_query_var( 'cpage', $cpage );
     34                $this->assertContains( 'cpage=2', get_next_comments_link( 'Next', 5 ) );
    3935        }
    40 
    4136}