WordPress.org

Make WordPress Core

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

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

    diff --git tests/phpunit/tests/link/getPreviousCommentsLink.php tests/phpunit/tests/link/getPreviousCommentsLink.php
    index ff4c088dea..1575282d5a 100644
     
    66 * @covers ::get_previous_comments_link
    77 */
    88class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase {
     9        /**
     10         * Post permalink.
     11         *
     12         * @var string
     13         */
     14        public static $post_permalink;
     15
     16        public static function wpSetUpBeforeClass( $factory ) {
     17                self::$post_permalink = get_permalink( $factory->post->create() );
     18        }
    919
    1020        public function test_page_should_respect_value_of_cpage_query_var() {
    11                 $p = self::factory()->post->create();
    12                 $this->go_to( get_permalink( $p ) );
    13 
    14                 $cpage = get_query_var( 'cpage' );
     21                $this->go_to( self::$post_permalink );
    1522                set_query_var( 'cpage', 3 );
    1623
    17                 $link = get_previous_comments_link( 'Next' );
    18 
    19                 $this->assertContains( 'cpage=2', $link );
    20 
    21                 set_query_var( 'cpage', $cpage );
     24                $this->assertContains( 'cpage=2', get_previous_comments_link( 'Next' ) );
    2225        }
    2326
    2427        public function test_page_should_default_to_1_when_no_cpage_query_var_is_found() {
    25                 $p = self::factory()->post->create();
    26                 $this->go_to( get_permalink( $p ) );
    27 
    28                 $cpage = get_query_var( 'cpage' );
     28                $this->go_to( self::$post_permalink );
    2929                set_query_var( 'cpage', '' );
    3030
    31                 $link = get_previous_comments_link( 'Next', 5 );
    32 
    33                 // Technically, it returns null here.
    34                 $this->assertEquals( '', $link );
    35 
    36                 set_query_var( 'cpage', $cpage );
     31                $this->assertNull( get_previous_comments_link( 'Next' ) );
    3732        }
    38 
    3933}