Make WordPress Core

Changeset 1191 in tests


Ignore:
Timestamp:
01/23/2013 05:46:26 AM (12 years ago)
Author:
SergeyBiryukov
Message:

Comment meta query tests for ordering by meta key. see #23208.

File:
1 edited

Legend:

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

    r1059 r1191  
    9292        add_comment_meta( $comment_id3, 'key3', 'value3', true );
    9393
     94        $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'key' ) ) );
     95        $this->assertEquals( 2, count( $comments ) );
     96        $this->assertEquals( $comment_id2, $comments[0]->comment_ID );
     97        $this->assertEquals( $comment_id, $comments[1]->comment_ID );
     98
    9499        $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'meta_value' ) ) );
    95100        $this->assertEquals( 2, count( $comments ) );
     
    97102        $this->assertEquals( $comment_id, $comments[1]->comment_ID );
    98103
     104        $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'key' ), 'order' => 'ASC' ) );
     105        $this->assertEquals( 2, count( $comments ) );
     106        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
     107        $this->assertEquals( $comment_id2, $comments[1]->comment_ID );
     108
    99109        $comments = get_comments( array( 'meta_key' => 'key', 'orderby' => array( 'meta_value' ), 'order' => 'ASC' ) );
    100110        $this->assertEquals( 2, count( $comments ) );
    101111        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
    102112        $this->assertEquals( $comment_id2, $comments[1]->comment_ID );
     113
     114        $comments = get_comments( array( 'meta_value' => 'value3', 'orderby' => array( 'key' ) ) );
     115        $this->assertEquals( 2, count( $comments ) );
     116        $this->assertEquals( $comment_id, $comments[0]->comment_ID );
     117        $this->assertEquals( $comment_id3, $comments[1]->comment_ID );
    103118
    104119        $comments = get_comments( array( 'meta_value' => 'value3', 'orderby' => array( 'meta_value' ) ) );
     
    109124        // value1 is present on two different keys for $comment_id yet we should get only one instance
    110125        // of that comment in the results
     126        $comments = get_comments( array( 'meta_value' => 'value1', 'orderby' => array( 'key' ) ) );
     127        $this->assertEquals( 1, count( $comments ) );
     128
    111129        $comments = get_comments( array( 'meta_value' => 'value1', 'orderby' => array( 'meta_value' ) ) );
    112130        $this->assertEquals( 1, count( $comments ) );
    113         }
     131    }
    114132
    115133    function test_get_status() {
Note: See TracChangeset for help on using the changeset viewer.