Fix logical errors in some comment pagination tests.
The tests included in [34669] contained a couple of problems: * Comments were not always created in the expected order, due to the incorrect use of 'comment_date_gmt'. * 'asc'/'desc' and 'older'/'newer' were confused. * 'default_comments_page=newest' ('last') didn't properly account for the cpage=1 offset. The code itself powering this pagination was correct; it's only the tests that were wrong. See #8071. git-svn-id: https://develop.svn.wordpress.org/trunk@34713 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
13aeda2ef7
commit
30a165a1a5
@ -15,12 +15,12 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'asc' );
|
update_option( 'comment_order', 'asc' );
|
||||||
@ -33,7 +33,7 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,12 +45,12 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'desc' );
|
update_option( 'comment_order', 'desc' );
|
||||||
@ -62,6 +62,36 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
// Life in the fast lane.
|
// Life in the fast lane.
|
||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
|
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 8071
|
||||||
|
*/
|
||||||
|
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() {
|
||||||
|
$now = time();
|
||||||
|
$p = $this->factory->post->create();
|
||||||
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '1',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
|
) );
|
||||||
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '2',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
|
) );
|
||||||
|
|
||||||
|
update_option( 'comment_order', 'asc' );
|
||||||
|
update_option( 'default_comments_page', 'oldest' );
|
||||||
|
|
||||||
|
$this->go_to( get_permalink( $p ) );
|
||||||
|
$found = get_echo( 'comments_template' );
|
||||||
|
|
||||||
|
// Life in the fast lane.
|
||||||
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
||||||
}
|
}
|
||||||
@ -69,21 +99,21 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 8071
|
* @ticket 8071
|
||||||
*/
|
*/
|
||||||
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest() {
|
public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() {
|
||||||
$now = time();
|
$now = time();
|
||||||
$p = $this->factory->post->create();
|
$p = $this->factory->post->create();
|
||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'asc' );
|
update_option( 'comment_order', 'desc' );
|
||||||
update_option( 'default_comments_page', 'oldest' );
|
update_option( 'default_comments_page', 'oldest' );
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) );
|
$this->go_to( get_permalink( $p ) );
|
||||||
@ -96,36 +126,6 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ticket 8071
|
|
||||||
*/
|
|
||||||
public function test_should_respect_comment_order_desc_when_default_comments_page_is_oldest() {
|
|
||||||
$now = time();
|
|
||||||
$p = $this->factory->post->create();
|
|
||||||
$comment_1 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '1',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
|
||||||
) );
|
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '2',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
|
||||||
) );
|
|
||||||
|
|
||||||
update_option( 'comment_order', 'desc' );
|
|
||||||
update_option( 'default_comments_page', 'oldest' );
|
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) );
|
|
||||||
$found = get_echo( 'comments_template' );
|
|
||||||
|
|
||||||
// Life in the fast lane.
|
|
||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
|
||||||
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 8071
|
* @ticket 8071
|
||||||
*/
|
*/
|
||||||
@ -135,68 +135,43 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
$comment_3 = $this->factory->comment->create( array(
|
$comment_3 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '3',
|
'comment_content' => '3',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
||||||
) );
|
) );
|
||||||
$comment_4 = $this->factory->comment->create( array(
|
$comment_4 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '4',
|
'comment_content' => '4',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
||||||
|
) );
|
||||||
|
$comment_5 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '3',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
|
||||||
|
) );
|
||||||
|
$comment_6 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '4',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'asc' );
|
update_option( 'comment_order', 'asc' );
|
||||||
update_option( 'default_comments_page', 'newest' );
|
update_option( 'default_comments_page', 'newest' );
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) . '?cpage=2&comments_per_page=2' );
|
$link = add_query_arg( array(
|
||||||
$found = get_echo( 'comments_template' );
|
'cpage' => 2,
|
||||||
|
'comments_per_page' => 2,
|
||||||
|
), get_permalink( $p ) );
|
||||||
|
|
||||||
// Life in the fast lane.
|
$this->go_to( $link );
|
||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
|
||||||
$this->assertSame( array( $comment_3, $comment_4 ), $found_cids );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ticket 8071
|
|
||||||
*/
|
|
||||||
public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() {
|
|
||||||
$now = time();
|
|
||||||
$p = $this->factory->post->create();
|
|
||||||
$comment_1 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '1',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
|
||||||
) );
|
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '2',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
|
||||||
) );
|
|
||||||
$comment_3 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '3',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
|
||||||
) );
|
|
||||||
$comment_4 = $this->factory->comment->create( array(
|
|
||||||
'comment_post_ID' => $p,
|
|
||||||
'comment_content' => '4',
|
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
|
||||||
) );
|
|
||||||
|
|
||||||
update_option( 'comment_order', 'desc' );
|
|
||||||
update_option( 'default_comments_page', 'newest' );
|
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) . '?cpage=2&comments_per_page=2' );
|
|
||||||
$found = get_echo( 'comments_template' );
|
$found = get_echo( 'comments_template' );
|
||||||
|
|
||||||
// Life in the fast lane.
|
// Life in the fast lane.
|
||||||
@ -209,41 +184,101 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
/**
|
/**
|
||||||
* @ticket 8071
|
* @ticket 8071
|
||||||
*/
|
*/
|
||||||
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() {
|
public function test_should_respect_comment_order_desc_when_default_comments_page_is_newest_on_subsequent_pages() {
|
||||||
$now = time();
|
$now = time();
|
||||||
$p = $this->factory->post->create();
|
$p = $this->factory->post->create();
|
||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
$comment_3 = $this->factory->comment->create( array(
|
$comment_3 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '3',
|
'comment_content' => '3',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
||||||
) );
|
) );
|
||||||
$comment_4 = $this->factory->comment->create( array(
|
$comment_4 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '4',
|
'comment_content' => '4',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
||||||
|
) );
|
||||||
|
$comment_5 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '3',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 500 ),
|
||||||
|
) );
|
||||||
|
$comment_6 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '4',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 600 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'asc' );
|
update_option( 'comment_order', 'desc' );
|
||||||
update_option( 'default_comments_page', 'oldest' );
|
update_option( 'default_comments_page', 'newest' );
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) . '?cpage=2&comments_per_page=2' );
|
$link = add_query_arg( array(
|
||||||
|
'cpage' => 2,
|
||||||
|
'comments_per_page' => 2,
|
||||||
|
), get_permalink( $p ) );
|
||||||
|
|
||||||
|
$this->go_to( $link );
|
||||||
$found = get_echo( 'comments_template' );
|
$found = get_echo( 'comments_template' );
|
||||||
|
|
||||||
// Life in the fast lane.
|
// Life in the fast lane.
|
||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
$this->assertSame( array( $comment_3, $comment_4 ), $found_cids );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 8071
|
||||||
|
*/
|
||||||
|
public function test_should_respect_comment_order_asc_when_default_comments_page_is_oldest_on_subsequent_pages() {
|
||||||
|
$now = time();
|
||||||
|
$p = $this->factory->post->create();
|
||||||
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '1',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
|
) );
|
||||||
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '2',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
|
) );
|
||||||
|
$comment_3 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '3',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
||||||
|
) );
|
||||||
|
$comment_4 = $this->factory->comment->create( array(
|
||||||
|
'comment_post_ID' => $p,
|
||||||
|
'comment_content' => '4',
|
||||||
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
||||||
|
) );
|
||||||
|
|
||||||
|
update_option( 'comment_order', 'asc' );
|
||||||
|
update_option( 'default_comments_page', 'oldest' );
|
||||||
|
|
||||||
|
$link = add_query_arg( array(
|
||||||
|
'cpage' => 2,
|
||||||
|
'comments_per_page' => 2,
|
||||||
|
), get_permalink( $p ) );
|
||||||
|
|
||||||
|
$this->go_to( $link );
|
||||||
|
$found = get_echo( 'comments_template' );
|
||||||
|
|
||||||
|
// Life in the fast lane.
|
||||||
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
|
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,34 +290,39 @@ class Tests_Comment_CommentsTemplate extends WP_UnitTestCase {
|
|||||||
$comment_1 = $this->factory->comment->create( array(
|
$comment_1 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '1',
|
'comment_content' => '1',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 100 ),
|
||||||
) );
|
) );
|
||||||
$comment_2 = $this->factory->comment->create( array(
|
$comment_2 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '2',
|
'comment_content' => '2',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 200 ),
|
||||||
) );
|
) );
|
||||||
$comment_3 = $this->factory->comment->create( array(
|
$comment_3 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '3',
|
'comment_content' => '3',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 300 ),
|
||||||
) );
|
) );
|
||||||
$comment_4 = $this->factory->comment->create( array(
|
$comment_4 = $this->factory->comment->create( array(
|
||||||
'comment_post_ID' => $p,
|
'comment_post_ID' => $p,
|
||||||
'comment_content' => '4',
|
'comment_content' => '4',
|
||||||
'comment_post_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 400 ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
update_option( 'comment_order', 'desc' );
|
update_option( 'comment_order', 'desc' );
|
||||||
update_option( 'default_comments_page', 'oldest' );
|
update_option( 'default_comments_page', 'oldest' );
|
||||||
|
|
||||||
$this->go_to( get_permalink( $p ) . '?cpage=2&comments_per_page=2' );
|
$link = add_query_arg( array(
|
||||||
|
'cpage' => 2,
|
||||||
|
'comments_per_page' => 2,
|
||||||
|
), get_permalink( $p ) );
|
||||||
|
|
||||||
|
$this->go_to( $link );
|
||||||
$found = get_echo( 'comments_template' );
|
$found = get_echo( 'comments_template' );
|
||||||
|
|
||||||
// Life in the fast lane.
|
// Life in the fast lane.
|
||||||
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
$comments = preg_match_all( '/id="comment-([0-9]+)"/', $found, $matches );
|
||||||
|
|
||||||
$found_cids = array_map( 'intval', $matches[1] );
|
$found_cids = array_map( 'intval', $matches[1] );
|
||||||
$this->assertSame( array( $comment_2, $comment_1 ), $found_cids );
|
$this->assertSame( array( $comment_1, $comment_2 ), $found_cids );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user