| | 111 | /** |
| | 112 | * @group 27282 |
| | 113 | */ |
| | 114 | public function test_stickies_more_than_posts_per_page_second_page() { |
| | 115 | // There are three stickies, get the second page of two. Is this composed of the |
| | 116 | // third sticky? |
| | 117 | $this->go_to( '/?paged=2&posts_per_page=2' ); |
| | 118 | $q = $GLOBALS['wp_query']; |
| | 119 | $this->assertEquals( $q->posts[0]->ID, self::$posts[14] ); |
| | 120 | } |
| | 121 | |
| | 122 | /** |
| | 123 | * @group 27282 |
| | 124 | */ |
| | 125 | public function test_stickies_not_included_in_initial_query_should_not_increase_number_of_results_returned() { |
| | 126 | $this->go_to( '/' ); |
| | 127 | $q = $GLOBALS['wp_query']; |
| | 128 | $this->assertEquals( $q->get( 'posts_per_page' ), count( $q->posts ) ); |
| | 129 | } |
| | 130 | |
| | 131 | /** |
| | 132 | * @group 27282 |
| | 133 | */ |
| | 134 | public function test_stickies_should_offset_starting_post_on_subsequent_pages() { |
| | 135 | $this->go_to( '/?paged=2' ); |
| | 136 | $q = $GLOBALS['wp_query']; |
| | 137 | |
| | 138 | /* |
| | 139 | * There are three stickies. Two (2 and 8) naturally appear on the first page. |
| | 140 | * The third (14) pads the first page by 1, offsetting the second page by 1. |
| | 141 | */ |
| | 142 | $this->assertEquals( self::$posts[9], $q->posts[0]->ID ); |
| | 143 | } |
| | 144 | |
| | 145 | /** |
| | 146 | * @group 27282 |
| | 147 | */ |
| | 148 | public function test_stickies_should_not_appear_in_their_normal_order_on_inner_pages() { |
| | 149 | $this->go_to( '/?paged=2' ); |
| | 150 | $q = $GLOBALS['wp_query']; |
| | 151 | |
| | 152 | $this->assertNotContains( self::$posts[14], wp_list_pluck( $q->posts, 'ID' ) ); |
| | 153 | } |
| | 154 | |