WordPress.org

Make WordPress Core

Ticket #27282: 27282.tests.diff

File 27282.tests.diff, 1.4 KB (added by boonebgorges, 5 years ago)
  • tests/phpunit/tests/query/stickies.php

    diff --git tests/phpunit/tests/query/stickies.php tests/phpunit/tests/query/stickies.php
    index 73ff746..eb0dca4 100644
    class Tests_Query_Stickies extends WP_UnitTestCase { 
    105105                $this->assertNotContains( self::$posts[8], wp_list_pluck( $q->posts, 'ID' ) );
    106106        }
    107107
     108        /**
     109         * @group 27282
     110         */
     111        public function test_stickies_not_included_in_initial_query_should_not_increase_number_of_results_returned() {
     112                $this->go_to( '/' );
     113                $q = $GLOBALS['wp_query'];
     114                $this->assertEquals( $q->get( 'posts_per_page' ), count( $q->posts ) );
     115        }
     116
     117        /**
     118         * @group 27282
     119         */
     120        public function test_stickies_should_offset_starting_post_on_subsequent_pages() {
     121                $this->go_to( '/?paged=2' );
     122                $q = $GLOBALS['wp_query'];
     123
     124                /*
     125                 * There are three stickies. Two (2 and 8) naturally appear on the first page.
     126                 * The third (14) pads the first page by 1, offsetting the second page by 1.
     127                 */
     128                $this->assertEquals( self::$posts[9], $q->posts[0]->ID );
     129        }
     130
     131        /**
     132         * @group 27282
     133         */
     134        public function test_stickies_should_not_appear_in_their_normal_order_on_inner_pages() {
     135                $this->go_to( '/?paged=2' );
     136                $q = $GLOBALS['wp_query'];
     137
     138                $this->assertNotContains( self::$posts[14], wp_list_pluck( $q->posts, 'ID' ) );
     139        }
     140
    108141        public function set_ignore_sticky_posts( $q ) {
    109142                $q->set( 'ignore_sticky_posts', true );
    110143        }