| | 131 | * @ticket 40293 |
| | 132 | */ |
| | 133 | public function test_should_handle_zero_comments_per_page_with_comments_broken_into_pages_and_last_page_displayed_by_default() { |
| | 134 | $now = time(); |
| | 135 | $p = self::factory()->post->create(); |
| | 136 | |
| | 137 | $comment_1 = self::factory()->comment->create( array( |
| | 138 | 'comment_post_ID' => $p, |
| | 139 | 'comment_content' => '1', |
| | 140 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ), |
| | 141 | ) ); |
| | 142 | $comment_2 = self::factory()->comment->create( array( |
| | 143 | 'comment_post_ID' => $p, |
| | 144 | 'comment_content' => '2', |
| | 145 | 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now ), |
| | 146 | ) ); |
| | 147 | |
| | 148 | update_option( 'comment_order', 'desc' ); |
| | 149 | update_option( 'default_comments_page', 'newest' ); // last (newest) page displayed by default |
| | 150 | update_option( 'comments_per_page', '0' ); // top level comments per page |
| | 151 | update_option( 'page_comments', '1' ); // break comments into pages |
| | 152 | |
| | 153 | $this->go_to( get_permalink( $p ) ); |
| | 154 | $found = get_echo( 'comments_template' ); |
| | 155 | |
| | 156 | preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches ); |
| | 157 | |
| | 158 | $found_cids = array_map( 'intval', $matches[1] ); |
| | 159 | $this->assertSame( array( $comment_2, $comment_1 ), $found_cids ); |
| | 160 | } |
| | 161 | |
| | 162 | /** |