Make WordPress Core


Ignore:
Timestamp:
09/28/2015 03:09:34 PM (11 years ago)
Author:
boonebgorges
Message:

Use correct 'page_id' parameter in get_page_of_comment().

See #34057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/getPageOfComment.php

    r34540 r34660  
    172172                $this->assertEquals( 2, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
    173173        }
     174
     175        /**
     176         * @ticket 34057
     177         */
     178        public function test_query_should_be_limited_to_comments_on_the_proper_post() {
     179                $posts = $this->factory->post->create_many( 2 );
     180
     181                $now = time();
     182                $comments_0 = $comments_1 = array();
     183                for ( $i = 0; $i < 5; $i++ ) {
     184                        $comments_0[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[0], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     185                        $comments_1[] = $this->factory->comment->create( array( 'comment_post_ID' => $posts[1], 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - ( $i * 60 ) ) ) );
     186                }
     187
     188                $found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) );
     189                $this->assertEquals( 3, $found_0 );
     190
     191                $found_1 = get_page_of_comment( $comments_1[1], array( 'per_page' => 2 ) );
     192                $this->assertEquals( 2, $found_1 );
     193        }
    174194}
Note: See TracChangeset for help on using the changeset viewer.