WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/02/2014 01:40:56 AM (6 years ago)
Author:
boonebgorges
Message:

WP_Comment_Query: commentin, commentnot_in, postin, postnot_in.

Props nofearinc, mordauk, boonebgorges

Fixes #25386

File:
1 edited

Legend:

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

    r29134 r29808  
    199199        $this->assertEqualSets( array( $comment_1, $comment_2, $comment_3 ), $comment_ids );
    200200    }
     201
     202    /**
     203     * @ticket 29189
     204     */
     205    function test_fields_comment__in() {
     206        $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     207        $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     208        $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     209
     210        $comment_ids = get_comments( array(
     211            'fields' => 'ids',
     212            'comment__in' => array( $comment_1, $comment_3 ),
     213        ) );
     214
     215        $this->assertEqualSets( array( $comment_1, $comment_3 ), $comment_ids );
     216    }
     217
     218    /**
     219     * @ticket 29189
     220     */
     221    function test_fields_comment__not_in() {
     222        $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     223        $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     224        $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     225
     226        $comment_ids = get_comments( array(
     227            'fields' => 'ids',
     228            'comment__not_in' => array( $comment_2, $comment_3 ),
     229        ) );
     230
     231        $this->assertEqualSets( array( $comment_1 ), $comment_ids );
     232    }
     233
     234    /**
     235     * @ticket 29189
     236     */
     237    function test_fields_post__in() {
     238        $p1 = $this->factory->post->create();
     239        $p2 = $this->factory->post->create();
     240        $p3 = $this->factory->post->create();
     241
     242        $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
     243        $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     244        $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     245
     246        $comment_ids = get_comments( array(
     247            'fields' => 'ids',
     248            'post__in' => array( $p1, $p2 ),
     249        ) );
     250
     251        $this->assertEqualSets( array( $c1, $c2 ), $comment_ids );
     252    }
     253
     254    /**
     255     * @ticket 29189
     256     */
     257    function test_fields_post__not_in() {
     258        $p1 = $this->factory->post->create();
     259        $p2 = $this->factory->post->create();
     260        $p3 = $this->factory->post->create();
     261
     262        $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) );
     263        $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) );
     264        $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) );
     265
     266        $comment_ids = get_comments( array(
     267            'fields' => 'ids',
     268            'post__not_in' => array( $p1, $p2 ),
     269        ) );
     270
     271        $this->assertEqualSets( array( $c3 ), $comment_ids );
     272    }
    201273}
Note: See TracChangeset for help on using the changeset viewer.