WordPress.org

Make WordPress Core

Changeset 31666


Ignore:
Timestamp:
03/07/2015 04:34:50 PM (6 years ago)
Author:
boonebgorges
Message:

Add tests for the conversion of 'meta_*' query vars to $meta_query objects in all query classes.

See #31265.

Location:
trunk/tests/phpunit/tests
Files:
3 edited

Legend:

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

    r31662 r31666  
    13521352    }
    13531353
     1354    public function test_meta_vars_should_be_converted_to_meta_query() {
     1355        $q = new WP_Comment_Query();
     1356        $q->query( array(
     1357            'meta_key' => 'foo',
     1358            'meta_value' => '5',
     1359            'meta_compare' => '>',
     1360            'meta_type' => 'SIGNED',
     1361        ) );
     1362
     1363        $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] );
     1364        $this->assertSame( '5', $q->meta_query->queries[0]['value'] );
     1365        $this->assertSame( '>', $q->meta_query->queries[0]['compare'] );
     1366        $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] );
     1367    }
     1368
    13541369    public function test_count() {
    13551370        $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) );
  • trunk/tests/phpunit/tests/query/metaQuery.php

    r31340 r31666  
    12091209    }
    12101210
     1211    public function test_meta_vars_should_be_converted_to_meta_query() {
     1212        $q = new WP_Query( array(
     1213            'meta_key' => 'foo',
     1214            'meta_value' => '5',
     1215            'meta_compare' => '>',
     1216            'meta_type' => 'SIGNED',
     1217        ) );
     1218
     1219        $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] );
     1220        $this->assertSame( '5', $q->meta_query->queries[0]['value'] );
     1221        $this->assertSame( '>', $q->meta_query->queries[0]['compare'] );
     1222        $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] );
     1223    }
     1224
    12111225    /**
    12121226     * @ticket 29604
  • trunk/tests/phpunit/tests/user/query.php

    r31663 r31666  
    353353        $query->prepare_query();
    354354        $this->assertEquals( $_query_vars, $query->query_vars );
     355    }
     356
     357    public function test_meta_vars_should_be_converted_to_meta_query() {
     358        $q = new WP_User_Query( array(
     359            'meta_key' => 'foo',
     360            'meta_value' => '5',
     361            'meta_compare' => '>',
     362            'meta_type' => 'SIGNED',
     363        ) );
     364
     365        $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] );
     366        $this->assertSame( '5', $q->meta_query->queries[0]['value'] );
     367        $this->assertSame( '>', $q->meta_query->queries[0]['compare'] );
     368        $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] );
    355369    }
    356370
Note: See TracChangeset for help on using the changeset viewer.