| | 241 | |
| | 242 | /** |
| | 243 | * @ticket 8973 |
| | 244 | */ |
| | 245 | public function test_page_number_when_user_has_unapproved_comments() { |
| | 246 | $p = self::factory()->post->create(); |
| | 247 | |
| | 248 | // page 3 |
| | 249 | $comment_last = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_date' => '2013-09-20 00:00:00' ) ); |
| | 250 | |
| | 251 | // page 2 |
| | 252 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_approved' => 0, 'comment_date' => '2013-09-19 00:00:00' ) ); |
| | 253 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_approved' => 0, 'comment_date' => '2013-09-18 00:00:00' ) ); |
| | 254 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_approved' => 0, 'comment_date' => '2013-09-17 00:00:00' ) ); |
| | 255 | |
| | 256 | // page 1 |
| | 257 | $unapproved = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_approved' => 0, 'comment_date' => '2013-09-16 00:00:00' ) ); |
| | 258 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_date' => '2013-09-15 00:00:00' ) ); |
| | 259 | self::factory()->comment->create_post_comments( $p, 1, array( 'comment_author' => 'Test Commenter', 'comment_author_email' => 'example@example.com', 'comment_date' => '2013-09-14 00:00:00' ) ); |
| | 260 | |
| | 261 | $this->assertEquals( 1, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) ); |
| | 262 | $this->assertEquals( 3, get_page_of_comment( $comment_last[0], array( 'per_page' => 3, 'include_unapproved' => 'example@example.com' ) ) ); |
| | 263 | |
| | 264 | self::factory()->comment->update_object( $unapproved[0], array( 'comment_approved' => 1 )); |
| | 265 | |
| | 266 | $this->assertEquals( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) ); |
| | 267 | $this->assertEquals( 3, get_page_of_comment( $comment_last[0], array( 'per_page' => 3, 'include_unapproved' => 'example@example.com' ) ) ); |
| | 268 | } |