diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 27a23870f8..55e7d730e3 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -1351,6 +1351,21 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertEquals( $comments, wp_list_pluck( $found, 'comment_ID' ) ); } + public function test_meta_vars_should_be_converted_to_meta_query() { + $q = new WP_Comment_Query(); + $q->query( array( + 'meta_key' => 'foo', + 'meta_value' => '5', + 'meta_compare' => '>', + 'meta_type' => 'SIGNED', + ) ); + + $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] ); + $this->assertSame( '5', $q->meta_query->queries[0]['value'] ); + $this->assertSame( '>', $q->meta_query->queries[0]['compare'] ); + $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] ); + } + public function test_count() { $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7 ) ); diff --git a/tests/phpunit/tests/query/metaQuery.php b/tests/phpunit/tests/query/metaQuery.php index 06217e03ac..c550e00ba0 100644 --- a/tests/phpunit/tests/query/metaQuery.php +++ b/tests/phpunit/tests/query/metaQuery.php @@ -1208,6 +1208,20 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), $query->posts ); } + public function test_meta_vars_should_be_converted_to_meta_query() { + $q = new WP_Query( array( + 'meta_key' => 'foo', + 'meta_value' => '5', + 'meta_compare' => '>', + 'meta_type' => 'SIGNED', + ) ); + + $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] ); + $this->assertSame( '5', $q->meta_query->queries[0]['value'] ); + $this->assertSame( '>', $q->meta_query->queries[0]['compare'] ); + $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] ); + } + /** * @ticket 29604 */ diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index 5738f4298f..36bef88b10 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -354,6 +354,20 @@ class Tests_User_Query extends WP_UnitTestCase { $this->assertEquals( $_query_vars, $query->query_vars ); } + public function test_meta_vars_should_be_converted_to_meta_query() { + $q = new WP_User_Query( array( + 'meta_key' => 'foo', + 'meta_value' => '5', + 'meta_compare' => '>', + 'meta_type' => 'SIGNED', + ) ); + + $this->assertSame( 'foo', $q->meta_query->queries[0]['key'] ); + $this->assertSame( '5', $q->meta_query->queries[0]['value'] ); + $this->assertSame( '>', $q->meta_query->queries[0]['compare'] ); + $this->assertSame( 'SIGNED', $q->meta_query->queries[0]['type'] ); + } + /** * @ticket 23849 */