Make WordPress Core


Ignore:
Timestamp:
07/09/2014 06:15:42 PM (11 years ago)
Author:
nacin
Message:

WP_Comment_Query: Add fields => 'ids' query var.

props mordauk.
fixes #28434.

File:
1 edited

Legend:

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

    r27258 r29045  
    181181
    182182    }
     183
     184    /**
     185     * @ticket 28434
     186     */
     187    function test_fields_ids_query() {
     188        $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) );
     189        $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     190        $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) );
     191
     192        // Ensure we are dealing with integers, and not objects.
     193        $this->assertInternalType( 'integer', $comment_1 );
     194        $this->assertInternalType( 'integer', $comment_2 );
     195        $this->assertInternalType( 'integer', $comment_3 );
     196
     197        $comment_ids = get_comments( array( 'fields' => 'ids' ) );
     198        $this->assertCount( 3, $comment_ids );
     199        $this->assertEquals( array( $comment_1, $comment_2, $comment_3 ), $comment_ids );
     200    }
    183201}
Note: See TracChangeset for help on using the changeset viewer.