<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[31286] trunk/tests/phpunit/tests: Improve organiation of tax_query and meta_query unit tests.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/31286">31286</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/31286","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-01-27 20:03:50 +0000 (Tue, 27 Jan 2015)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Improve organiation of tax_query and meta_query unit tests.

`meta_query` tests have been moved to `tests/phpunit/tests/query/metaQuery.php` and `tax_query` tests to `tests/phpunit/tests/query/taxQuery.php`. This is an improvement because (a) it better corresponds to the way that other `WP_Query` parameter tests are organized, (b) splitting meta and tax tests into separate classes simplifies the required `@group` annotations, and (c) the tests have nothing to do with posts per se, and so do not belong in the `post` subdirectory.

The tests previously found at `tests/phpunit/tests/query/taxQuery.php` have been moved to `isTerm.php` in the same directory. These tests are related to the `is_*` functions that have to do with taxonomy terms, like `is_category()`.

See <a href="https://core.trac.wordpress.org/ticket/26999">#26999</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestspostqueryphp">trunk/tests/phpunit/tests/post/query.php</a></li>
<li><a href="#trunktestsphpunittestsquerytaxQueryphp">trunk/tests/phpunit/tests/query/taxQuery.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsqueryisTermphp">trunk/tests/phpunit/tests/query/isTerm.php</a></li>
<li><a href="#trunktestsphpunittestsquerymetaQueryphp">trunk/tests/phpunit/tests/query/metaQuery.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestspostqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/query.php  2015-01-26 19:03:09 UTC (rev 31285)
+++ trunk/tests/phpunit/tests/post/query.php    2015-01-27 20:03:50 UTC (rev 31286)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,2634 +6,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group meta
-        */
-       public function test_meta_query_no_key() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'oof', 'bar' );
-               add_post_meta( $p3, 'oof', 'baz' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'value' => 'bar',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1, $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_no_value() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'oof', 'bar' );
-               add_post_meta( $p3, 'oof', 'baz' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'oof',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2, $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_default() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'bar',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_equals() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'bar',
-                                       'compare' => '=',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_not_equals() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'bar',
-                                       'compare' => '!=',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_arithmetic_comparisons() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', '1' );
-               add_post_meta( $p2, 'foo', '2' );
-               add_post_meta( $p3, 'foo', '3' );
-
-               // <
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 2,
-                                       'compare' => '<',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               // <=
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 2,
-                                       'compare' => '<=',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1, $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               // >=
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 2,
-                                       'compare' => '>=',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2, $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               // >
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 2,
-                                       'compare' => '>',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_like() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'ba',
-                                       'compare' => 'LIKE',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_not_like() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'foo', 'rab' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'ba',
-                                       'compare' => 'NOT LIKE',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_between_not_between() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', '1' );
-               add_post_meta( $p2, 'foo', '10' );
-               add_post_meta( $p3, 'foo', '100' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => array( 9, 12 ),
-                                       'compare' => 'BETWEEN',
-                                       'type' => 'NUMERIC',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => array( 9, 12 ),
-                                       'compare' => 'NOT BETWEEN',
-                                       'type' => 'NUMERIC',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1, $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_regexp_rlike() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'z$',
-                                       'compare' => 'REGEXP',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               // RLIKE is a synonym for REGEXP.
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'z$',
-                                       'compare' => 'RLIKE',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p2 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_single_query_compare_not_regexp() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'z$',
-                                       'compare' => 'NOT REGEXP',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_relation_default() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'foo value 1' );
-               add_post_meta( $p1, 'bar', 'bar value 1' );
-               add_post_meta( $p2, 'foo', 'foo value 1' );
-               add_post_meta( $p2, 'bar', 'bar value 2' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'foo value 1',
-                               ),
-                               array(
-                                       'key' => 'bar',
-                                       'value' => 'bar value 1',
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1 );
-               $this->assertEquals( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_relation_or() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'foo', rand_str() );
-               add_post_meta( $post_id, 'foo', rand_str() );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'bar', 'val2' );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'baz', rand_str() );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'froo', rand_str() );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'tango', 'val2' );
-               $post_id6 = $this->factory->post->create();
-               add_post_meta( $post_id6, 'bar', 'val1' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo'
-                               ),
-                               array(
-                                       'key' => 'bar',
-                                       'value' => 'val2'
-                               ),
-                               array(
-                                       'key' => 'baz'
-                               ),
-                               array(
-                                       'key' => 'froo'
-                               ),
-                               'relation' => 'OR',
-                       ),
-               ) );
-
-               $expected = array( $post_id, $post_id2, $post_id3, $post_id4 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       public function test_meta_query_relation_and() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'foo', rand_str() );
-               add_post_meta( $post_id, 'foo', rand_str() );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'bar', 'val2' );
-               add_post_meta( $post_id2, 'foo', rand_str() );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'baz', rand_str() );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'froo', rand_str() );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'tango', 'val2' );
-               $post_id6 = $this->factory->post->create();
-               add_post_meta( $post_id6, 'bar', 'val1' );
-               add_post_meta( $post_id6, 'foo', rand_str() );
-               $post_id7 = $this->factory->post->create();
-               add_post_meta( $post_id7, 'foo', rand_str() );
-               add_post_meta( $post_id7, 'froo', rand_str() );
-               add_post_meta( $post_id7, 'baz', rand_str() );
-               add_post_meta( $post_id7, 'bar', 'val2' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo'
-                               ),
-                               array(
-                                       'key' => 'bar',
-                                       'value' => 'val2'
-                               ),
-                               array(
-                                       'key' => 'baz'
-                               ),
-                               array(
-                                       'key' => 'froo'
-                               ),
-                               'relation' => 'AND',
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $post_id7 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo'
-                               ),
-                               array(
-                                       'key' => 'bar',
-                               ),
-                               'relation' => 'AND',
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $post_id2, $post_id6, $post_id7 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 30681
-        */
-       public function test_meta_query_compare_exists() {
-               $posts = $this->factory->post->create_many( 3 );
-               add_post_meta( $posts[0], 'foo', 'bar' );
-               add_post_meta( $posts[2], 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'compare' => 'EXISTS',
-                                       'key' => 'foo',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $posts[0], $posts[2] ), $query->posts );
-       }
-
-       /**
-        * @ticket 30681
-        */
-       public function test_meta_query_compare_exists_with_value_should_convert_to_equals() {
-               $posts = $this->factory->post->create_many( 3 );
-               add_post_meta( $posts[0], 'foo', 'bar' );
-               add_post_meta( $posts[2], 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'compare' => 'EXISTS',
-                                       'value' => 'baz',
-                                       'key' => 'foo',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $posts[2] ), $query->posts );
-       }
-
-       /**
-        * @ticket 30681
-        */
-       public function test_meta_query_compare_not_exists_should_ignore_value() {
-               $posts = $this->factory->post->create_many( 3 );
-               add_post_meta( $posts[0], 'foo', 'bar' );
-               add_post_meta( $posts[2], 'foo', 'baz' );
-
-               $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               array(
-                                       'compare' => 'NOT EXISTS',
-                                       'value' => 'bar',
-                                       'key' => 'foo',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $posts[1] ), $query->posts );
-       }
-
-       /**
-        * @ticket 18158
-        * @group meta
-        */
-       public function test_meta_query_compare_not_exists() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'foo', rand_str() );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'bar', rand_str() );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'bar', rand_str() );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'baz', rand_str() );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'foo', rand_str() );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $post_id2, $post_id3, $post_id4 );
-               $this->assertEqualSets( $expected, $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                               array(
-                                       'key' => 'bar',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $post_id4 );
-               $this->assertEquals( $expected, $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'foo',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                               array(
-                                       'key' => 'bar',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                               array(
-                                       'key' => 'baz',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $this->assertEquals( 0, count( $query->posts ) );
-       }
-
-       /**
-        * @ticket 29062
-        */
-       public function test_meta_query_compare_not_exists_with_another_condition_relation_or() {
-               $posts = $this->factory->post->create_many( 4 );
-               update_post_meta( $posts[0], 'color', 'orange' );
-               update_post_meta( $posts[1], 'color', 'blue' );
-               update_post_meta( $posts[1], 'vegetable', 'onion' );
-               update_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $post_3_meta = get_post_meta( $posts[3] );
-               foreach ( $post_3_meta as $meta_key => $meta_value ) {
-                       delete_post_meta( $posts[3], $meta_key );
-               }
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                               ),
-                               array(
-                                       'key' => 'color',
-                                       'compare' => 'NOT EXISTS',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[1], $posts[2], $posts[3] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_or_compare_equals() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'shallot',
-                                       'compare' => '=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[1], $posts[2] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_or_compare_equals_different_keys() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'color',
-                                       'value' => 'orange',
-                                       'compare' => '=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[0], $posts[1] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_or_compare_equals_and_in() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'color',
-                                       'value' => array( 'orange', 'green' ),
-                                       'compare' => 'IN',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[0], $posts[1] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_or_compare_equals_and_like() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'hall',
-                                       'compare' => 'LIKE',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[1], $posts[2] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_or_compare_equals_and_between() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'number_of_colors', '2' );
-               add_post_meta( $posts[1], 'number_of_colors', '5' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'shallot',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'number_of_colors',
-                                       'value' => array( 1, 3 ),
-                                       'compare' => 'BETWEEN',
-                                       'type' => 'SIGNED',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[0], $posts[2] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_in_same_keys() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-               add_post_meta( $posts[3], 'vegetable', 'banana' );
-               add_post_meta( $posts[3], 'vegetable', 'onion' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => array( 'onion', 'shallot' ),
-                                       'compare' => 'IN',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => array( 'banana' ),
-                                       'compare' => 'IN',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[3] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_in_different_keys() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[1], 'vegetable', 'shallot' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-               add_post_meta( $posts[3], 'vegetable', 'banana' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => array( 'onion', 'shallot' ),
-                                       'compare' => 'IN',
-                               ),
-                               array(
-                                       'key' => 'color',
-                                       'value' => array( 'blue' ),
-                                       'compare' => 'IN',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[1] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_not_equals() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-               add_post_meta( $posts[3], 'vegetable', 'banana' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '!=',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'shallot',
-                                       'compare' => '!=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[3] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_not_equals_different_keys() {
-               $posts = $this->factory->post->create_many( 4 );
-
-               // !shallot, but orange.
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[0], 'vegetable', 'onion' );
-
-               // !orange, but shallot.
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'shallot' );
-
-               // Neither.
-               add_post_meta( $posts[2], 'color', 'blue' );
-               add_post_meta( $posts[2], 'vegetable', 'onion' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'shallot',
-                                       'compare' => '!=',
-                               ),
-                               array(
-                                       'key' => 'color',
-                                       'value' => 'orange',
-                                       'compare' => '!=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[2] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_not_equals_not_in() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-               add_post_meta( $posts[3], 'vegetable', 'banana' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '!=',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => array( 'shallot' ),
-                                       'compare' => 'NOT IN',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[3] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 24093
-        */
-       public function test_meta_query_relation_and_compare_not_equals_and_not_like() {
-               $posts = $this->factory->post->create_many( 4 );
-               add_post_meta( $posts[0], 'color', 'orange' );
-               add_post_meta( $posts[1], 'color', 'blue' );
-               add_post_meta( $posts[1], 'vegetable', 'onion' );
-               add_post_meta( $posts[2], 'vegetable', 'shallot' );
-               add_post_meta( $posts[3], 'vegetable', 'banana' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'onion',
-                                       'compare' => '!=',
-                               ),
-                               array(
-                                       'key' => 'vegetable',
-                                       'value' => 'hall',
-                                       'compare' => 'NOT LIKE',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $expected = array( $posts[3] );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 23033
-        * @group meta
-        */
-       public function test_meta_query_decimal_results() {
-               $post_1 = $this->factory->post->create();
-               $post_2 = $this->factory->post->create();
-               $post_3 = $this->factory->post->create();
-               $post_4 = $this->factory->post->create();
-
-               update_post_meta( $post_1, 'decimal_value', '-0.3' );
-               update_post_meta( $post_2, 'decimal_value', '0.23409844' );
-               update_post_meta( $post_3, 'decimal_value', '0.3' );
-               update_post_meta( $post_4, 'decimal_value', '0.4' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '.300',
-                                       'compare' => '=',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_3 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '0.35',
-                                       'compare' => '>',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_4 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '0.3',
-                                       'compare' => '>=',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_3, $post_4 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '0',
-                                       'compare' => '<',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_1 ), $query->posts, 'ID' );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '0.3',
-                                       'compare' => '<=',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_1, $post_2, $post_3 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => array( 0.23409845, .31 ),
-                                       'compare' => 'BETWEEN',
-                                       'type' => 'DECIMAL(10, 10)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_3 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => array( 0.23409845, .31 ),
-                                       'compare' => 'NOT BETWEEN',
-                                       'type' => 'DECIMAL(10,10)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_1, $post_2, $post_4 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '.3',
-                                       'compare' => 'LIKE',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_1, $post_3 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'meta_query' => array(
-                               array(
-                                       'key' => 'decimal_value',
-                                       'value' => '.3',
-                                       'compare' => 'NOT LIKE',
-                                       'type' => 'DECIMAL(10,2)'
-                               )
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_2, $post_4 ), $query->posts );
-
-               $query = new WP_Query( array(
-                       'orderby' => 'meta_value',
-                       'order' => 'DESC',
-                       'meta_key' => 'decimal_value',
-                       'meta_type' => 'DECIMAL(10, 2)',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-               $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), $query->posts );
-       }
-
-       /**
-        * @group meta
-        * @ticket 29604
-        */
-       public function test_meta_query_with_orderby_meta_value_relation_or() {
-               $posts = $this->factory->post->create_many( 4 );
-               update_post_meta( $posts[0], 'foo', 5 );
-               update_post_meta( $posts[1], 'foo', 6 );
-               update_post_meta( $posts[2], 'foo', 4 );
-               update_post_meta( $posts[3], 'foo', 7 );
-
-               update_post_meta( $posts[0], 'bar1', 'baz' );
-               update_post_meta( $posts[1], 'bar1', 'baz' );
-               update_post_meta( $posts[2], 'bar2', 'baz' );
-
-               $query = new WP_Query( array(
-                       'orderby' => 'meta_value',
-                       'order' => 'ASC',
-                       'meta_key' => 'foo',
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'bar1',
-                                       'value' => 'baz',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'bar2',
-                                       'value' => 'baz',
-                                       'compare' => '=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts );
-       }
-
-       /**
-        * @group meta
-        * @ticket 29604
-        */
-       public function test_meta_query_with_orderby_meta_value_relation_and() {
-               $posts = $this->factory->post->create_many( 4 );
-               update_post_meta( $posts[0], 'foo', 5 );
-               update_post_meta( $posts[1], 'foo', 6 );
-               update_post_meta( $posts[2], 'foo', 4 );
-               update_post_meta( $posts[3], 'foo', 7 );
-
-               update_post_meta( $posts[0], 'bar1', 'baz' );
-               update_post_meta( $posts[1], 'bar1', 'baz' );
-               update_post_meta( $posts[2], 'bar1', 'baz' );
-               update_post_meta( $posts[3], 'bar1', 'baz' );
-               update_post_meta( $posts[0], 'bar2', 'baz' );
-               update_post_meta( $posts[1], 'bar2', 'baz' );
-               update_post_meta( $posts[2], 'bar2', 'baz' );
-
-               $query = new WP_Query( array(
-                       'orderby' => 'meta_value',
-                       'order' => 'ASC',
-                       'meta_key' => 'foo',
-                       'meta_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'key' => 'bar1',
-                                       'value' => 'baz',
-                                       'compare' => '=',
-                               ),
-                               array(
-                                       'key' => 'bar2',
-                                       'value' => 'baz',
-                                       'compare' => '=',
-                               ),
-                       ),
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'fields' => 'ids',
-               ) );
-
-               $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts );
-       }
-
-       /**
-        * @ticket 29642
-        * @group meta
-        */
-       public function test_meta_query_nested() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p2, 'foo2', 'bar' );
-               add_post_meta( $p3, 'foo2', 'bar' );
-               add_post_meta( $p3, 'foo3', 'bar' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_term_meta_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'bar',
-                               ),
-                               array(
-                                       'relation' => 'AND',
-                                       array(
-                                               'key' => 'foo2',
-                                               'value' => 'bar',
-                                       ),
-                                       array(
-                                               'key' => 'foo3',
-                                               'value' => 'bar',
-                                       ),
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1, $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @ticket 29642
-        * @group meta
-        */
-       public function test_meta_query_nested_two_levels_deep() {
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               add_post_meta( $p1, 'foo', 'bar' );
-               add_post_meta( $p3, 'foo2', 'bar' );
-               add_post_meta( $p3, 'foo3', 'bar' );
-               add_post_meta( $p3, 'foo4', 'bar' );
-
-               $query = new WP_Query( array(
-                       'update_post_meta_cache' => false,
-                       'update_term_meta_cache' => false,
-                       'fields' => 'ids',
-                       'meta_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'key' => 'foo',
-                                       'value' => 'bar',
-                               ),
-                               array(
-                                       'relation' => 'OR',
-                                       array(
-                                               'key' => 'foo2',
-                                               'value' => 'bar',
-                                       ),
-                                       array(
-                                               'relation' => 'AND',
-                                               array(
-                                                       'key' => 'foo3',
-                                                       'value' => 'bar',
-                                               ),
-                                               array(
-                                                       'key' => 'foo4',
-                                                       'value' => 'bar',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               ) );
-
-               $expected = array( $p1, $p3 );
-               $this->assertEqualSets( $expected, $query->posts );
-       }
-
-       /**
-        * @group meta
-        */
-       function test_meta_between_not_between() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'time', 500 );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'time', 1001 );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'time', 0 );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'time', 1 );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'time', 1000 );
-
-               $args = array(
-                       'meta_key' => 'time',
-                       'meta_value' => array( 1, 1000 ),
-                       'meta_type' => 'numeric',
-                       'meta_compare' => 'NOT BETWEEN'
-                       );
-
-               $query = new WP_Query( $args );
-               $this->assertEquals( 2, count ( $query->posts ) );
-               foreach ( $query->posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $query->posts, 'ID' );
-               $this->assertEqualSets( array( $post_id2, $post_id3 ), $posts );
-
-               $args = array(
-                       'meta_key' => 'time',
-                       'meta_value' => array( 1, 1000 ),
-                       'meta_type' => 'numeric',
-                       'meta_compare' => 'BETWEEN'
-                       );
-
-               $query = new WP_Query( $args );
-               $this->assertEquals( 3, count ( $query->posts ) );
-               foreach ( $query->posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $query->posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id4, $post_id5 ), $posts );
-       }
-
-       /**
-        * @ticket 16829
-        * @group meta
-        */
-       function test_meta_default_compare() {
-               // compare should default to IN when meta_value is an array
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'foo', 'bar' );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'bar', 'baz' );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'foo', 'baz' );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'baz', 'bar' );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'foo', rand_str() );
-
-               $posts = get_posts( array(
-                       'meta_key' => 'foo',
-                       'meta_value' => array( 'bar', 'baz' )
-               ) );
-
-               $this->assertEquals( 2, count( $posts ) );
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id3 ), $posts );
-
-               $posts = get_posts( array(
-                       'meta_key' => 'foo',
-                       'meta_value' => array( 'bar', 'baz' ),
-                       'meta_compare' => 'IN'
-               ) );
-
-               $this->assertEquals( 2, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id3 ), $posts );
-       }
-
-       /**
-        * @ticket 17264
-        * @group meta
-        */
-       function test_duplicate_posts_when_no_key() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'city', 'Lorem' );
-               add_post_meta( $post_id, 'address', '123 Lorem St.' );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'city', 'Lorem' );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'city', 'Loren' );
-
-               $args = array(
-                       'meta_query' => array(
-                       array(
-                               'value' => 'lorem',
-                               'compare' => 'LIKE'
-                       )
-                       )
-               );
-
-               $posts = get_posts( $args );
-               $this->assertEquals( 2, count( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id2 ), $posts );
-       }
-
-       /**
-        * @ticket 15292
-        * @group meta
-        */
-       function test_empty_meta_value() {
-               $post_id = $this->factory->post->create();
-               add_post_meta( $post_id, 'foo', '0' );
-               add_post_meta( $post_id, 'bar', 0 );
-               $post_id2 = $this->factory->post->create();
-               add_post_meta( $post_id2, 'foo', 1 );
-               $post_id3 = $this->factory->post->create();
-               add_post_meta( $post_id3, 'baz', 0 );
-               $post_id4 = $this->factory->post->create();
-               add_post_meta( $post_id4, 'baz', 0 );
-               $post_id5 = $this->factory->post->create();
-               add_post_meta( $post_id5, 'baz', 0 );
-               add_post_meta( $post_id5, 'bar', '0' );
-               $post_id6 = $this->factory->post->create();
-               add_post_meta( $post_id6, 'baz', 0 );
-
-               $q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) );
-               $this->assertEquals( 1, count ( $q->posts ) );
-               foreach ( $q->posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $this->assertEquals( $post_id, $q->posts[0]->ID );
-
-               $posts = get_posts( array( 'meta_key' => 'bar', 'meta_value' => '0' ) );
-               $this->assertEquals( 2, count ( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id5 ), $posts );
-
-               $posts = get_posts( array( 'meta_key' => 'bar', 'meta_value' => 0 ) );
-               $this->assertEquals( 2, count ( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id5 ), $posts );
-
-               $posts = get_posts( array( 'meta_value' => 0 ) );
-               $this->assertEquals( 5, count ( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts );
-
-               $posts = get_posts( array( 'meta_value' => '0' ) );
-               $this->assertEquals( 5, count ( $posts ) );
-               foreach ( $posts as $post ) {
-                       $this->assertInstanceOf( 'WP_Post', $post );
-                       $this->assertEquals( 'raw', $post->filter );
-               }
-               $posts = wp_list_pluck( $posts, 'ID' );
-               $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts );
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * @group taxonomy
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_tax_query_single_query_single_term_field_slug() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_field_name() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'Foo' ),
-                                       'field' => 'name',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_field_term_taxonomy_id() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               $tt_ids = wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => $tt_ids,
-                                       'field' => 'term_taxonomy_id',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_field_term_id() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( $t ),
-                                       'field' => 'term_id',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_operator_in() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                                       'operator' => 'IN',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_operator_not_in() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                                       'operator' => 'NOT IN',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p2 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_single_term_operator_and() {
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                                       'operator' => 'AND',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p1 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_multiple_terms_operator_in() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t1, 'category' );
-               wp_set_post_terms( $p2, $t2, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo', 'bar' ),
-                                       'field' => 'slug',
-                                       'operator' => 'IN',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_multiple_terms_operator_not_in() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t1, 'category' );
-               wp_set_post_terms( $p2, $t2, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo', 'bar' ),
-                                       'field' => 'slug',
-                                       'operator' => 'NOT IN',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p3 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        * @ticket 18105
-        */
-       public function test_tax_query_single_query_multiple_queries_operator_not_in() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_post_terms( $p1, $t1, 'category' );
-               wp_set_post_terms( $p2, $t2, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                                       'operator' => 'NOT IN',
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'bar' ),
-                                       'field' => 'slug',
-                                       'operator' => 'NOT IN',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p3 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_single_query_multiple_terms_operator_and() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, $t1, 'category' );
-               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo', 'bar' ),
-                                       'field' => 'slug',
-                                       'operator' => 'AND',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29181
-        */
-       public function test_tax_query_operator_not_exists() {
-               register_taxonomy( 'wptests_tax1', 'post' );
-               register_taxonomy( 'wptests_tax2', 'post' );
-
-               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
-               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
-               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'wptests_tax2',
-                                       'operator' => 'NOT EXISTS',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p1, $p3 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29181
-        */
-       public function test_tax_query_operator_exists() {
-               register_taxonomy( 'wptests_tax1', 'post' );
-               register_taxonomy( 'wptests_tax2', 'post' );
-
-               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
-               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
-               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'wptests_tax2',
-                                       'operator' => 'EXISTS',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29181
-        */
-       public function test_tax_query_operator_exists_should_ignore_terms() {
-               register_taxonomy( 'wptests_tax1', 'post' );
-               register_taxonomy( 'wptests_tax2', 'post' );
-
-               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
-               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
-               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'wptests_tax2',
-                                       'operator' => 'EXISTS',
-                                       'terms' => array( 'foo', 'bar' ),
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29181
-        */
-       public function test_tax_query_operator_exists_with_no_taxonomy() {
-               register_taxonomy( 'wptests_tax1', 'post' );
-               register_taxonomy( 'wptests_tax2', 'post' );
-
-               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
-               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
-               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               array(
-                                       'operator' => 'EXISTS',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEmpty( $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_multiple_queries_relation_and() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, $t1, 'category' );
-               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'bar' ),
-                                       'field' => 'slug',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( array( $p2 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_multiple_queries_relation_or() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, $t1, 'category' );
-               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'bar' ),
-                                       'field' => 'slug',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_multiple_queries_different_taxonomies() {
-               $t1 = $this->factory->term->create( array(
-                       'taxonomy' => 'post_tag',
-                       'slug' => 'foo',
-                       'name' => 'Foo',
-               ) );
-               $t2 = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-                       'name' => 'Bar',
-               ) );
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, $t1, 'post_tag' );
-               wp_set_object_terms( $p2, $t2, 'category' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'terms' => array( 'foo' ),
-                                       'field' => 'slug',
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( 'bar' ),
-                                       'field' => 'slug',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29738
-        * @group taxonomy
-        */
-       public function test_tax_query_two_nested_queries() {
-               register_taxonomy( 'foo', 'post' );
-               register_taxonomy( 'bar', 'post' );
-
-               $foo_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $foo_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $bar_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-               $bar_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
-               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
-               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
-               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'relation' => 'AND',
-                                       array(
-                                               'taxonomy' => 'foo',
-                                               'terms' => array( $foo_term_1 ),
-                                               'field' => 'term_id',
-                                       ),
-                                       array(
-                                               'taxonomy' => 'bar',
-                                               'terms' => array( $bar_term_1 ),
-                                               'field' => 'term_id',
-                                       ),
-                               ),
-                               array(
-                                       'relation' => 'AND',
-                                       array(
-                                               'taxonomy' => 'foo',
-                                               'terms' => array( $foo_term_2 ),
-                                               'field' => 'term_id',
-                                       ),
-                                       array(
-                                               'taxonomy' => 'bar',
-                                               'terms' => array( $bar_term_2 ),
-                                               'field' => 'term_id',
-                                       ),
-                               ),
-                       ),
-               ) );
-
-               _unregister_taxonomy( 'foo' );
-               _unregister_taxonomy( 'bar' );
-
-               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29738
-        * @group taxonomy
-        */
-       public function test_tax_query_one_nested_query_one_first_order_query() {
-               register_taxonomy( 'foo', 'post' );
-               register_taxonomy( 'bar', 'post' );
-
-               $foo_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $foo_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $bar_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-               $bar_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
-               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
-               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
-               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $foo_term_2 ),
-                                       'field' => 'term_id',
-                               ),
-                               array(
-                                       'relation' => 'AND',
-                                       array(
-                                               'taxonomy' => 'foo',
-                                               'terms' => array( $foo_term_1 ),
-                                               'field' => 'term_id',
-                                       ),
-                                       array(
-                                               'taxonomy' => 'bar',
-                                               'terms' => array( $bar_term_1 ),
-                                               'field' => 'term_id',
-                                       ),
-                               ),
-                       ),
-               ) );
-
-               _unregister_taxonomy( 'foo' );
-               _unregister_taxonomy( 'bar' );
-
-               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
-       }
-
-       /**
-        * @ticket 29738
-        * @group taxonomy
-        */
-       public function test_tax_query_one_double_nested_query_one_first_order_query() {
-               register_taxonomy( 'foo', 'post' );
-               register_taxonomy( 'bar', 'post' );
-
-               $foo_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $foo_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $bar_term_1 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-               $bar_term_2 = $this->factory->term->create( array(
-                       'taxonomy' => 'bar',
-               ) );
-
-               $p1 = $this->factory->post->create();
-               $p2 = $this->factory->post->create();
-               $p3 = $this->factory->post->create();
-               $p4 = $this->factory->post->create();
-
-               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
-               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
-               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
-               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
-               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
-
-               $q = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $foo_term_2 ),
-                                       'field' => 'term_id',
-                               ),
-                               array(
-                                       'relation' => 'AND',
-                                       array(
-                                               'taxonomy' => 'foo',
-                                               'terms' => array( $foo_term_1 ),
-                                               'field' => 'term_id',
-                                       ),
-                                       array(
-                                               'relation' => 'OR',
-                                               array(
-                                                       'taxonomy' => 'bar',
-                                                       'terms' => array( $bar_term_1 ),
-                                                       'field' => 'term_id',
-                                               ),
-                                               array(
-                                                       'taxonomy' => 'bar',
-                                                       'terms' => array( $bar_term_2 ),
-                                                       'field' => 'term_id',
-                                               ),
-                                       ),
-                               ),
-                       ),
-               ) );
-
-               _unregister_taxonomy( 'foo' );
-               _unregister_taxonomy( 'bar' );
-
-               $this->assertEqualSets( array( $p1, $p2, $p3 ), $q->posts );
-       }
-
-       /**
-        * @ticket 20604
-        * @group taxonomy
-        */
-       public function test_tax_query_relation_or_both_clauses_empty_terms() {
-               // An empty tax query should return an empty array, not all posts.
-
-               $this->factory->post->create_many( 10 );
-
-               $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_term_cache' => false,
-                       'update_post_meta_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'field' => 'id',
-                                       'terms' => false,
-                                       'operator' => 'IN'
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => false,
-                                       'operator' => 'IN'
-                               ),
-                       )
-               ) );
-
-               $posts = $query->get_posts();
-               $this->assertEquals( 0 , count( $posts ) );
-       }
-
-       /**
-        * @ticket 20604
-        * @group taxonomy
-        */
-       public function test_tax_query_relation_or_one_clause_empty_terms() {
-               // An empty tax query should return an empty array, not all posts.
-
-               $this->factory->post->create_many( 10 );
-
-               $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_term_cache' => false,
-                       'update_post_meta_cache' => false,
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'field' => 'id',
-                                       'terms' => array( 'foo' ),
-                                       'operator' => 'IN'
-                               ),
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => false,
-                                       'operator' => 'IN'
-                               ),
-                       )
-               ) );
-
-               $posts = $query->get_posts();
-               $this->assertEquals( 0 , count( $posts ) );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_tax_query_include_children() {
-               $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
-               $cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
-               $cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
-               $cat_d = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
-
-               $post_a = $this->factory->post->create( array( 'post_category' => array( $cat_a ) ) );
-               $post_b = $this->factory->post->create( array( 'post_category' => array( $cat_b ) ) );
-               $post_c = $this->factory->post->create( array( 'post_category' => array( $cat_c ) ) );
-               $post_d = $this->factory->post->create( array( 'post_category' => array( $cat_d ) ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_a ),
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 4 , count( $posts ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_a ),
-                                       'include_children' => false
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 1 , count( $posts ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_b ),
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 3 , count( $posts ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_b ),
-                                       'include_children' => false
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 1 , count( $posts ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_c ),
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 1 , count( $posts ) );
-
-               $posts = get_posts( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'id',
-                                       'terms' => array( $cat_c ),
-                                       'include_children' => false
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( 1 , count( $posts ) );
-       }
-
-       /**
-        * @group taxonomy
-        */
</del><span class="cx" style="display: block; padding: 0 10px">         function test_category__and_var() {
</span><span class="cx" style="display: block; padding: 0 10px">                $q = new WP_Query();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2663,160 +37,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group taxonomy
-        */
-       public function test_tax_query_taxonomy_with_attachments() {
-               $q = new WP_Query();
-
-               register_taxonomy_for_object_type( 'post_tag', 'attachment:image' );
-               $tag_id = $this->factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
-               $image_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
-                       'post_mime_type' => 'image/jpeg',
-                       'post_type' => 'attachment'
-               ) );
-               wp_set_object_terms( $image_id, $tag_id, 'post_tag' );
-
-               $posts = $q->query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'post_type' => 'attachment',
-                       'post_status' => 'inherit',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'field' => 'term_id',
-                                       'terms' => array( $tag_id )
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( array( $image_id ), $posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       function test_tax_query_no_taxonomy() {
-               $cat_id = $this->factory->category->create( array( 'name' => 'alpha' ) );
-               $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
-
-               $response1 = new WP_Query( array(
-                       'tax_query' => array(
-                               array( 'terms' => array( $cat_id ) )
-                       )
-               ) );
-               $this->assertEmpty( $response1->posts );
-
-               $response2 = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( $cat_id )
-                               )
-                       )
-               ) );
-               $this->assertNotEmpty( $response2->posts );
-
-               $term = get_category( $cat_id );
-               $response3 = new WP_Query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'tax_query' => array(
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $term->term_taxonomy_id )
-                               )
-                       )
-               ) );
-               $this->assertNotEmpty( $response3->posts );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       function test_term_taxonomy_id_field_no_taxonomy() {
-               $q = new WP_Query();
-
-               $posts = $this->factory->post->create_many( 5 );
-
-               $cats = $tags = array();
-
-               // need term_taxonomy_ids in addition to term_ids, so no factory
-               for ( $i = 0; $i < 5; $i++ ) {
-                       $cats[$i] = wp_insert_term( 'category-' . $i , 'category' );
-                       $tags[$i] = wp_insert_term( 'tag-' . $i, 'post_tag' );
-
-                       // post 0 gets all terms
-                       wp_set_object_terms( $posts[0], array( $cats[$i]['term_id'] ), 'category', true );
-                       wp_set_object_terms( $posts[0], array( $tags[$i]['term_id'] ), 'post_tag', true );
-               }
-
-               wp_set_object_terms( $posts[1], array( $cats[0]['term_id'], $cats[2]['term_id'], $cats[4]['term_id'] ), 'category' );
-               wp_set_object_terms( $posts[1], array( $tags[0]['term_id'], $tags[2]['term_id'], $cats[4]['term_id'] ), 'post_tag' );
-
-               wp_set_object_terms( $posts[2], array( $cats[1]['term_id'], $cats[3]['term_id'] ), 'category' );
-               wp_set_object_terms( $posts[2], array( $tags[1]['term_id'], $tags[3]['term_id'] ), 'post_tag' );
-
-               wp_set_object_terms( $posts[3], array( $cats[0]['term_id'], $cats[2]['term_id'], $cats[4]['term_id'] ), 'category' );
-               wp_set_object_terms( $posts[3], array( $tags[1]['term_id'], $tags[3]['term_id'] ), 'post_tag' );
-
-               $results1 = $q->query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               'relation' => 'OR',
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $cats[0]['term_taxonomy_id'], $cats[2]['term_taxonomy_id'], $cats[4]['term_taxonomy_id'], $tags[0]['term_taxonomy_id'], $tags[2]['term_taxonomy_id'], $cats[4]['term_taxonomy_id'] ),
-                                       'operator' => 'AND',
-                                       'include_children' => false,
-                               ),
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $cats[1]['term_taxonomy_id'], $cats[3]['term_taxonomy_id'], $tags[1]['term_taxonomy_id'], $tags[3]['term_taxonomy_id'] ),
-                                       'operator' => 'AND',
-                                       'include_children' => false,
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( array( $posts[0], $posts[1], $posts[2] ), $results1, 'Relation: OR; Operator: AND' );
-
-               $results2 = $q->query( array(
-                       'fields' => 'ids',
-                       'update_post_meta_cache' => false,
-                       'update_post_term_cache' => false,
-                       'orderby' => 'ID',
-                       'order' => 'ASC',
-                       'tax_query' => array(
-                               'relation' => 'AND',
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $cats[0]['term_taxonomy_id'], $tags[0]['term_taxonomy_id'] ),
-                                       'operator' => 'IN',
-                                       'include_children' => false,
-                               ),
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $cats[3]['term_taxonomy_id'], $tags[3]['term_taxonomy_id'] ),
-                                       'operator' => 'IN',
-                                       'include_children' => false,
-                               )
-                       )
-               ) );
-
-               $this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' );
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * @ticket 28099
</span><span class="cx" style="display: block; padding: 0 10px">         * @group taxonomy
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2847,204 +67,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group taxonomy
-        * @ticket 29738
-        */
-       public function test_populate_taxonomy_query_var_from_tax_query() {
-               register_taxonomy( 'foo', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $c = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-               ) );
-
-               $q = new WP_Query( array(
-                       'tax_query' => array(
-                               // Empty terms mean that this one should be skipped
-                               array(
-                                       'taxonomy' => 'bar',
-                                       'terms' => array(),
-                               ),
-
-                               // Category and post tags should be skipped
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( $c ),
-                               ),
-
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $t ),
-                               ),
-                       ),
-               ) );
-
-               $this->assertSame( 'foo', $q->get( 'taxonomy' ) );
-
-               _unregister_taxonomy( 'foo' );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() {
-               register_taxonomy( 'foo', 'post' );
-               register_taxonomy( 'foo1', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-
-               $q = new WP_Query( array(
-                       'taxonomy' => 'bar',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $t ),
-                               ),
-                       ),
-               ) );
-
-               $this->assertSame( 'bar', $q->get( 'taxonomy' ) );
-
-               _unregister_taxonomy( 'foo' );
-               _unregister_taxonomy( 'foo1' );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_populate_term_query_var_from_tax_query() {
-               register_taxonomy( 'foo', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-                       'slug' => 'bar',
-               ) );
-
-               $q = new WP_Query( array(
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( 'bar' ),
-                                       'field' => 'slug',
-                               ),
-                       ),
-               ) );
-
-               $this->assertSame( 'bar', $q->get( 'term' ) );
-
-               _unregister_taxonomy( 'foo' );
-       }
-
-       /**
-        * @group taxonomy
-        */
-       public function test_populate_term_id_query_var_from_tax_query() {
-               register_taxonomy( 'foo', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-                       'slug' => 'bar',
-               ) );
-
-               $q = new WP_Query( array(
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $t ),
-                                       'field' => 'term_id',
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( $t, $q->get( 'term_id' ) );
-
-               _unregister_taxonomy( 'foo' );
-       }
-
-       /**
-        * @group taxonomy
-        * @ticket 29738
-        */
-       public function test_populate_cat_category_name_query_var_from_tax_query() {
-               register_taxonomy( 'foo', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $c = $this->factory->term->create( array(
-                       'taxonomy' => 'category',
-                       'slug' => 'bar',
-               ) );
-
-               $q = new WP_Query( array(
-                       'tax_query' => array(
-                               // Non-category should be skipped
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $t ),
-                               ),
-
-                               // Empty terms mean that this one should be skipped
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array(),
-                               ),
-
-                               // Category and post tags should be skipped
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( $c ),
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( $c, $q->get( 'cat' ) );
-               $this->assertEquals( 'bar', $q->get( 'category_name' ) );
-
-               _unregister_taxonomy( 'foo' );
-       }
-
-       /**
-        * @group taxonomy
-        * @ticket 29738
-        */
-       public function test_populate_tag_id_query_var_from_tax_query() {
-               register_taxonomy( 'foo', 'post' );
-               $t = $this->factory->term->create( array(
-                       'taxonomy' => 'foo',
-               ) );
-               $tag = $this->factory->term->create( array(
-                       'taxonomy' => 'post_tag',
-                       'slug' => 'bar',
-               ) );
-
-               $q = new WP_Query( array(
-                       'tax_query' => array(
-                               // Non-tag should be skipped
-                               array(
-                                       'taxonomy' => 'foo',
-                                       'terms' => array( $t ),
-                               ),
-
-                               // Empty terms mean that this one should be skipped
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'terms' => array(),
-                               ),
-
-                               // Category and post tags should be skipped
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'terms' => array( $tag ),
-                               ),
-                       ),
-               ) );
-
-               $this->assertEquals( $tag, $q->get( 'tag_id' ) );
-
-               _unregister_taxonomy( 'foo' );
-       }
-
-       /**
</del><span class="cx" style="display: block; padding: 0 10px">          * @ticket 22448
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        function test_the_posts_filter() {
</span></span></pre></div>
<a id="trunktestsphpunittestsqueryisTermphpfromrev31285trunktestsphpunittestsquerytaxQueryphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/query/isTerm.php (from rev 31285, trunk/tests/phpunit/tests/query/taxQuery.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/query/isTerm.php                                (rev 0)
+++ trunk/tests/phpunit/tests/query/isTerm.php  2015-01-27 20:03:50 UTC (rev 31286)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,283 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * Test the is_*() functions in query.php related to taxonomy terms across the URL structure.
+ *
+ * This exercises both query.php and rewrite.php: urls are fed through the rewrite code,
+ * then we test the effects of each url on the wp_query object.
+ *
+ * @group query
+ * @group rewrite
+ * @group taxonomy
+ */
+class Tests_Query_IsTerm extends WP_UnitTestCase {
+       protected $tag_id;
+       protected $cat_id;
+       protected $tax_id;
+       protected $tax_id2;
+       protected $post_id;
+
+       protected $cat;
+       protected $uncat;
+       protected $tag;
+       protected $tax;
+
+       function setUp() {
+               global $wp_rewrite;
+               parent::setUp();
+
+               set_current_screen( 'front' );
+
+               $GLOBALS['wp_the_query'] = new WP_Query();
+               $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
+
+               $wp_rewrite->init();
+               $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
+
+               create_initial_taxonomies();
+               register_taxonomy( 'testtax', 'post', array( 'public' => true ) );
+
+               $wp_rewrite->flush_rules();
+
+               $this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
+               $this->cat_id = $this->factory->category->create( array( 'slug' => 'cat-slug' ) );
+               $this->tax_id = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
+               $this->tax_id2 = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
+               $this->post_id = $this->factory->post->create();
+               wp_set_object_terms( $this->post_id, $this->cat_id, 'category' );
+               wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' );
+
+               $this->cat = get_term( $this->cat_id, 'category' );
+               _make_cat_compat( $this->cat );
+               $this->tag = get_term( $this->tag_id, 'post_tag' );
+
+               $this->uncat = get_term_by( 'slug', 'uncategorized', 'category' );
+               _make_cat_compat( $this->uncat );
+
+               add_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
+       }
+
+       function tearDown() {
+               global $wp_rewrite;
+               parent::tearDown();
+
+               _unregister_taxonomy( 'testtax' );
+
+               $wp_rewrite->init();
+
+               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
+       }
+
+       function test_tag_action_tax() {
+               // tag with tax added
+               $this->go_to( home_url( "/tag/tag-slug/" ) );
+               $this->assertQueryTrue( 'is_tag', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
+               $this->assertEquals( get_queried_object(), $this->tag );
+       }
+
+       function test_tag_query_cat_action_tax() {
+               // tag + category with tax added
+               $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id" ) );
+               $this->assertQueryTrue( 'is_category', 'is_tag', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertNotEmpty( get_query_var( 'cat' ) );
+               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
+               $this->assertEquals( get_queried_object(), $this->cat );
+       }
+
+       function test_tag_query_cat_query_tax_action_tax() {
+               // tag + category + tax with tax added
+               $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id&testtax=tax-slug2" ) );
+               $this->assertQueryTrue( 'is_category', 'is_tag', 'is_tax', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertNotEmpty( get_query_var( 'cat' ) );
+               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
+               $this->assertNotEmpty( get_query_var( 'testtax' ) );
+               $this->assertEquals( get_queried_object(), $this->cat );
+       }
+
+       function test_cat_action_tax() {
+               // category with tax added
+               $this->go_to( home_url( "/category/cat-slug/" ) );
+               $this->assertQueryTrue( 'is_category', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'cat' ) );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertEquals( get_queried_object(), $this->cat );
+       }
+
+       /**
+        * @ticket 26627
+        */
+       function test_cat_uncat_action_tax() {
+               // category with tax added
+               add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 );
+
+               $this->go_to( home_url( "/category/uncategorized/" ) );
+               $this->assertQueryTrue( 'is_category', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'cat' ) );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertEquals( get_queried_object(), $this->uncat );
+
+               remove_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 );
+       }
+
+       function _cat_uncat_action_tax( &$query ) {
+               $this->assertTrue( $query->is_category() );
+               $this->assertTrue( $query->is_archive() );
+               $this->assertNotEmpty( $query->get( 'category_name' ) );
+               $this->assertNotEmpty( $query->get( 'tax_query' ) );
+               $this->assertEquals( $query->get_queried_object(), $this->uncat );
+       }
+
+       /**
+        * @ticket 26728
+        */
+       function test_tax_action_tax() {
+               // tax with tax added
+               $this->go_to( home_url( '/testtax/tax-slug2/' ) );
+               $this->assertQueryTrue( 'is_tax', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertEquals( get_queried_object(), get_term( $this->tax_id, 'testtax' ) );
+       }
+
+       function test_tax_query_tag_action_tax() {
+               // tax + tag with tax added
+               $this->go_to( home_url( "/testtax/tax-slug2/?tag_id=$this->tag_id" ) );
+               $this->assertQueryTrue( 'is_tag', 'is_tax', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
+               $this->assertEquals( get_queried_object(), $this->tag );
+       }
+
+       function test_tax_query_cat_action_tax() {
+               // tax + cat with tax added
+               $this->go_to( home_url( "/testtax/tax-slug2/?cat=$this->cat_id" ) );
+               $this->assertQueryTrue( 'is_category', 'is_tax', 'is_archive' );
+               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
+               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
+               $this->assertNotEmpty( get_query_var( 'term_id' ) );
+               $this->assertNotEmpty( get_query_var( 'cat' ) );
+               $this->assertEquals( get_queried_object(), $this->cat );
+       }
+
+       function pre_get_posts_tax_category_tax_query( &$query ) {
+               $query->set( 'tax_query', array(
+                       array( 'taxonomy' => 'testtax', 'field' => 'term_id', 'terms' => $this->tax_id )
+               ) );
+       }
+
+       /**
+        * @group 30623
+        */
+       public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_term_id_should_return_term_object() {
+               // Don't override the args provided below.
+               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
+
+               $args = array(
+                       'tax_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'taxonomy' => 'testtax',
+                                       'field' => 'term_id',
+                                       'terms' => array(
+                                               $this->tax_id,
+                                       ),
+                               ),
+                       )
+               );
+
+               $q = new WP_Query( $args );
+               $object = $q->get_queried_object();
+
+               $expected = get_term( $this->tax_id, 'testtax' );
+
+               $this->assertEquals( $expected, $object );
+       }
+
+       /**
+        * @group 30623
+        */
+       public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_slug_should_return_term_object() {
+               // Don't override the args provided below.
+               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
+
+               $args = array(
+                       'tax_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'taxonomy' => 'testtax',
+                                       'field' => 'slug',
+                                       'terms' => array(
+                                               'tax-slug',
+                                       ),
+                               ),
+                       )
+               );
+
+               $q = new WP_Query( $args );
+               $object = $q->get_queried_object();
+
+               $expected = get_term( $this->tax_id, 'testtax' );
+
+               // Only compare term_id because object_id may or may not be part of either value.
+               $this->assertEquals( $expected->term_id, $object->term_id );
+       }
+
+       /**
+        * @group 30623
+        */
+       public function test_get_queried_object_with_custom_taxonomy_tax_query_with_multiple_clauses_should_return_term_object_corresponding_to_the_first_queried_tax() {
+               // Don't override the args provided below.
+               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
+
+               register_taxonomy( 'testtax2', 'post' );
+               $testtax2_term_id = $this->factory->term->create( array(
+                       'taxonomy' => 'testtax2',
+                       'slug' => 'testtax2-slug',
+               ) );
+
+               $args = array(
+                       'tax_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'taxonomy' => 'testtax',
+                                       'field' => 'slug',
+                                       'terms' => array(
+                                               'tax-slug',
+                                       ),
+                               ),
+                               array(
+                                       'taxonomy' => 'testtax2',
+                                       'field' => 'slug',
+                                       'terms' => array(
+                                               'testtax2-slug',
+                                       ),
+                               ),
+                       )
+               );
+
+               $q = new WP_Query( $args );
+               $object = $q->get_queried_object();
+
+               $expected = get_term( $this->tax_id, 'testtax' );
+
+               // Only compare term_id because object_id may or may not be part of either value.
+               $this->assertEquals( $expected->term_id, $object->term_id );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsquerymetaQueryphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/query/metaQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/query/metaQuery.php                             (rev 0)
+++ trunk/tests/phpunit/tests/query/metaQuery.php       2015-01-27 20:03:50 UTC (rev 31286)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,1561 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * @group query
+ * @group meta
+ */
+class Tests_Query_MetaQuery extends WP_UnitTestCase {
+       public function test_meta_query_no_key() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'oof', 'bar' );
+               add_post_meta( $p3, 'oof', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'value' => 'bar',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_no_value() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'oof', 'bar' );
+               add_post_meta( $p3, 'oof', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'oof',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_default() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_equals() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                                       'compare' => '=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_not_equals() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                                       'compare' => '!=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_arithmetic_comparisons() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', '1' );
+               add_post_meta( $p2, 'foo', '2' );
+               add_post_meta( $p3, 'foo', '3' );
+
+               // <
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '<',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // <=
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '<=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // >=
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '>=',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // >
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 2,
+                                       'compare' => '>',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_like() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'ba',
+                                       'compare' => 'LIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_not_like() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'rab' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'ba',
+                                       'compare' => 'NOT LIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_between_not_between() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', '1' );
+               add_post_meta( $p2, 'foo', '10' );
+               add_post_meta( $p3, 'foo', '100' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => array( 9, 12 ),
+                                       'compare' => 'BETWEEN',
+                                       'type' => 'NUMERIC',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => array( 9, 12 ),
+                                       'compare' => 'NOT BETWEEN',
+                                       'type' => 'NUMERIC',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_regexp_rlike() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'REGEXP',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               // RLIKE is a synonym for REGEXP.
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'RLIKE',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p2 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_single_query_compare_not_regexp() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'z$',
+                                       'compare' => 'NOT REGEXP',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_relation_default() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'foo value 1' );
+               add_post_meta( $p1, 'bar', 'bar value 1' );
+               add_post_meta( $p2, 'foo', 'foo value 1' );
+               add_post_meta( $p2, 'bar', 'bar value 2' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'foo value 1',
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'value' => 'bar value 1',
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1 );
+               $this->assertEquals( $expected, $query->posts );
+       }
+
+       public function test_meta_query_relation_or() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'foo', rand_str() );
+               add_post_meta( $post_id, 'foo', rand_str() );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'bar', 'val2' );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'baz', rand_str() );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'froo', rand_str() );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'tango', 'val2' );
+               $post_id6 = $this->factory->post->create();
+               add_post_meta( $post_id6, 'bar', 'val1' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo'
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'value' => 'val2'
+                               ),
+                               array(
+                                       'key' => 'baz'
+                               ),
+                               array(
+                                       'key' => 'froo'
+                               ),
+                               'relation' => 'OR',
+                       ),
+               ) );
+
+               $expected = array( $post_id, $post_id2, $post_id3, $post_id4 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_query_relation_and() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'foo', rand_str() );
+               add_post_meta( $post_id, 'foo', rand_str() );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'bar', 'val2' );
+               add_post_meta( $post_id2, 'foo', rand_str() );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'baz', rand_str() );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'froo', rand_str() );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'tango', 'val2' );
+               $post_id6 = $this->factory->post->create();
+               add_post_meta( $post_id6, 'bar', 'val1' );
+               add_post_meta( $post_id6, 'foo', rand_str() );
+               $post_id7 = $this->factory->post->create();
+               add_post_meta( $post_id7, 'foo', rand_str() );
+               add_post_meta( $post_id7, 'froo', rand_str() );
+               add_post_meta( $post_id7, 'baz', rand_str() );
+               add_post_meta( $post_id7, 'bar', 'val2' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo'
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'value' => 'val2'
+                               ),
+                               array(
+                                       'key' => 'baz'
+                               ),
+                               array(
+                                       'key' => 'froo'
+                               ),
+                               'relation' => 'AND',
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $post_id7 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo'
+                               ),
+                               array(
+                                       'key' => 'bar',
+                               ),
+                               'relation' => 'AND',
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $post_id2, $post_id6, $post_id7 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 30681
+        */
+       public function test_meta_query_compare_exists() {
+               $posts = $this->factory->post->create_many( 3 );
+               add_post_meta( $posts[0], 'foo', 'bar' );
+               add_post_meta( $posts[2], 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'compare' => 'EXISTS',
+                                       'key' => 'foo',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $posts[0], $posts[2] ), $query->posts );
+       }
+
+       /**
+        * @ticket 30681
+        */
+       public function test_meta_query_compare_exists_with_value_should_convert_to_equals() {
+               $posts = $this->factory->post->create_many( 3 );
+               add_post_meta( $posts[0], 'foo', 'bar' );
+               add_post_meta( $posts[2], 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'compare' => 'EXISTS',
+                                       'value' => 'baz',
+                                       'key' => 'foo',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $posts[2] ), $query->posts );
+       }
+
+       /**
+        * @ticket 30681
+        */
+       public function test_meta_query_compare_not_exists_should_ignore_value() {
+               $posts = $this->factory->post->create_many( 3 );
+               add_post_meta( $posts[0], 'foo', 'bar' );
+               add_post_meta( $posts[2], 'foo', 'baz' );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               array(
+                                       'compare' => 'NOT EXISTS',
+                                       'value' => 'bar',
+                                       'key' => 'foo',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $posts[1] ), $query->posts );
+       }
+
+       /**
+        * @ticket 18158
+        */
+       public function test_meta_query_compare_not_exists() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'foo', rand_str() );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'bar', rand_str() );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'bar', rand_str() );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'baz', rand_str() );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'foo', rand_str() );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $post_id2, $post_id3, $post_id4 );
+               $this->assertEqualSets( $expected, $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $post_id4 );
+               $this->assertEquals( $expected, $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'foo',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                               array(
+                                       'key' => 'bar',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                               array(
+                                       'key' => 'baz',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $this->assertEquals( 0, count( $query->posts ) );
+       }
+
+       /**
+        * @ticket 29062
+        */
+       public function test_meta_query_compare_not_exists_with_another_condition_relation_or() {
+               $posts = $this->factory->post->create_many( 4 );
+               update_post_meta( $posts[0], 'color', 'orange' );
+               update_post_meta( $posts[1], 'color', 'blue' );
+               update_post_meta( $posts[1], 'vegetable', 'onion' );
+               update_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $post_3_meta = get_post_meta( $posts[3] );
+               foreach ( $post_3_meta as $meta_key => $meta_value ) {
+                       delete_post_meta( $posts[3], $meta_key );
+               }
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                               ),
+                               array(
+                                       'key' => 'color',
+                                       'compare' => 'NOT EXISTS',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[1], $posts[2], $posts[3] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_or_compare_equals() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'shallot',
+                                       'compare' => '=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[1], $posts[2] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_or_compare_equals_different_keys() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'color',
+                                       'value' => 'orange',
+                                       'compare' => '=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[0], $posts[1] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_or_compare_equals_and_in() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'color',
+                                       'value' => array( 'orange', 'green' ),
+                                       'compare' => 'IN',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[0], $posts[1] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_or_compare_equals_and_like() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'hall',
+                                       'compare' => 'LIKE',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[1], $posts[2] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_or_compare_equals_and_between() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'number_of_colors', '2' );
+               add_post_meta( $posts[1], 'number_of_colors', '5' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'shallot',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'number_of_colors',
+                                       'value' => array( 1, 3 ),
+                                       'compare' => 'BETWEEN',
+                                       'type' => 'SIGNED',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[0], $posts[2] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_in_same_keys() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+               add_post_meta( $posts[3], 'vegetable', 'banana' );
+               add_post_meta( $posts[3], 'vegetable', 'onion' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => array( 'onion', 'shallot' ),
+                                       'compare' => 'IN',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => array( 'banana' ),
+                                       'compare' => 'IN',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[3] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_in_different_keys() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[1], 'vegetable', 'shallot' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+               add_post_meta( $posts[3], 'vegetable', 'banana' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => array( 'onion', 'shallot' ),
+                                       'compare' => 'IN',
+                               ),
+                               array(
+                                       'key' => 'color',
+                                       'value' => array( 'blue' ),
+                                       'compare' => 'IN',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[1] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_not_equals() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+               add_post_meta( $posts[3], 'vegetable', 'banana' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '!=',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'shallot',
+                                       'compare' => '!=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[3] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_not_equals_different_keys() {
+               $posts = $this->factory->post->create_many( 4 );
+
+               // !shallot, but orange.
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[0], 'vegetable', 'onion' );
+
+               // !orange, but shallot.
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'shallot' );
+
+               // Neither.
+               add_post_meta( $posts[2], 'color', 'blue' );
+               add_post_meta( $posts[2], 'vegetable', 'onion' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'shallot',
+                                       'compare' => '!=',
+                               ),
+                               array(
+                                       'key' => 'color',
+                                       'value' => 'orange',
+                                       'compare' => '!=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[2] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_not_equals_not_in() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+               add_post_meta( $posts[3], 'vegetable', 'banana' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '!=',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => array( 'shallot' ),
+                                       'compare' => 'NOT IN',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[3] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 24093
+        */
+       public function test_meta_query_relation_and_compare_not_equals_and_not_like() {
+               $posts = $this->factory->post->create_many( 4 );
+               add_post_meta( $posts[0], 'color', 'orange' );
+               add_post_meta( $posts[1], 'color', 'blue' );
+               add_post_meta( $posts[1], 'vegetable', 'onion' );
+               add_post_meta( $posts[2], 'vegetable', 'shallot' );
+               add_post_meta( $posts[3], 'vegetable', 'banana' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'onion',
+                                       'compare' => '!=',
+                               ),
+                               array(
+                                       'key' => 'vegetable',
+                                       'value' => 'hall',
+                                       'compare' => 'NOT LIKE',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $expected = array( $posts[3] );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 23033
+        */
+       public function test_meta_query_decimal_results() {
+               $post_1 = $this->factory->post->create();
+               $post_2 = $this->factory->post->create();
+               $post_3 = $this->factory->post->create();
+               $post_4 = $this->factory->post->create();
+
+               update_post_meta( $post_1, 'decimal_value', '-0.3' );
+               update_post_meta( $post_2, 'decimal_value', '0.23409844' );
+               update_post_meta( $post_3, 'decimal_value', '0.3' );
+               update_post_meta( $post_4, 'decimal_value', '0.4' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.300',
+                                       'compare' => '=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_3 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.35',
+                                       'compare' => '>',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_4 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.3',
+                                       'compare' => '>=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_3, $post_4 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0',
+                                       'compare' => '<',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_1 ), $query->posts, 'ID' );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '0.3',
+                                       'compare' => '<=',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_1, $post_2, $post_3 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => array( 0.23409845, .31 ),
+                                       'compare' => 'BETWEEN',
+                                       'type' => 'DECIMAL(10, 10)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_3 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => array( 0.23409845, .31 ),
+                                       'compare' => 'NOT BETWEEN',
+                                       'type' => 'DECIMAL(10,10)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_1, $post_2, $post_4 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.3',
+                                       'compare' => 'LIKE',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_1, $post_3 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'meta_query' => array(
+                               array(
+                                       'key' => 'decimal_value',
+                                       'value' => '.3',
+                                       'compare' => 'NOT LIKE',
+                                       'type' => 'DECIMAL(10,2)'
+                               )
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_2, $post_4 ), $query->posts );
+
+               $query = new WP_Query( array(
+                       'orderby' => 'meta_value',
+                       'order' => 'DESC',
+                       'meta_key' => 'decimal_value',
+                       'meta_type' => 'DECIMAL(10, 2)',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+               $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), $query->posts );
+       }
+
+       /**
+        * @ticket 29604
+        */
+       public function test_meta_query_with_orderby_meta_value_relation_or() {
+               $posts = $this->factory->post->create_many( 4 );
+               update_post_meta( $posts[0], 'foo', 5 );
+               update_post_meta( $posts[1], 'foo', 6 );
+               update_post_meta( $posts[2], 'foo', 4 );
+               update_post_meta( $posts[3], 'foo', 7 );
+
+               update_post_meta( $posts[0], 'bar1', 'baz' );
+               update_post_meta( $posts[1], 'bar1', 'baz' );
+               update_post_meta( $posts[2], 'bar2', 'baz' );
+
+               $query = new WP_Query( array(
+                       'orderby' => 'meta_value',
+                       'order' => 'ASC',
+                       'meta_key' => 'foo',
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'bar1',
+                                       'value' => 'baz',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'bar2',
+                                       'value' => 'baz',
+                                       'compare' => '=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts );
+       }
+
+       /**
+        * @ticket 29604
+        */
+       public function test_meta_query_with_orderby_meta_value_relation_and() {
+               $posts = $this->factory->post->create_many( 4 );
+               update_post_meta( $posts[0], 'foo', 5 );
+               update_post_meta( $posts[1], 'foo', 6 );
+               update_post_meta( $posts[2], 'foo', 4 );
+               update_post_meta( $posts[3], 'foo', 7 );
+
+               update_post_meta( $posts[0], 'bar1', 'baz' );
+               update_post_meta( $posts[1], 'bar1', 'baz' );
+               update_post_meta( $posts[2], 'bar1', 'baz' );
+               update_post_meta( $posts[3], 'bar1', 'baz' );
+               update_post_meta( $posts[0], 'bar2', 'baz' );
+               update_post_meta( $posts[1], 'bar2', 'baz' );
+               update_post_meta( $posts[2], 'bar2', 'baz' );
+
+               $query = new WP_Query( array(
+                       'orderby' => 'meta_value',
+                       'order' => 'ASC',
+                       'meta_key' => 'foo',
+                       'meta_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'key' => 'bar1',
+                                       'value' => 'baz',
+                                       'compare' => '=',
+                               ),
+                               array(
+                                       'key' => 'bar2',
+                                       'value' => 'baz',
+                                       'compare' => '=',
+                               ),
+                       ),
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'fields' => 'ids',
+               ) );
+
+               $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts );
+       }
+
+       /**
+        * @ticket 29642
+        */
+       public function test_meta_query_nested() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p2, 'foo2', 'bar' );
+               add_post_meta( $p3, 'foo2', 'bar' );
+               add_post_meta( $p3, 'foo3', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_term_meta_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                               ),
+                               array(
+                                       'relation' => 'AND',
+                                       array(
+                                               'key' => 'foo2',
+                                               'value' => 'bar',
+                                       ),
+                                       array(
+                                               'key' => 'foo3',
+                                               'value' => 'bar',
+                                       ),
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       /**
+        * @ticket 29642
+        */
+       public function test_meta_query_nested_two_levels_deep() {
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               add_post_meta( $p1, 'foo', 'bar' );
+               add_post_meta( $p3, 'foo2', 'bar' );
+               add_post_meta( $p3, 'foo3', 'bar' );
+               add_post_meta( $p3, 'foo4', 'bar' );
+
+               $query = new WP_Query( array(
+                       'update_post_meta_cache' => false,
+                       'update_term_meta_cache' => false,
+                       'fields' => 'ids',
+                       'meta_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'key' => 'foo',
+                                       'value' => 'bar',
+                               ),
+                               array(
+                                       'relation' => 'OR',
+                                       array(
+                                               'key' => 'foo2',
+                                               'value' => 'bar',
+                                       ),
+                                       array(
+                                               'relation' => 'AND',
+                                               array(
+                                                       'key' => 'foo3',
+                                                       'value' => 'bar',
+                                               ),
+                                               array(
+                                                       'key' => 'foo4',
+                                                       'value' => 'bar',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               ) );
+
+               $expected = array( $p1, $p3 );
+               $this->assertEqualSets( $expected, $query->posts );
+       }
+
+       public function test_meta_between_not_between() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'time', 500 );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'time', 1001 );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'time', 0 );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'time', 1 );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'time', 1000 );
+
+               $args = array(
+                       'meta_key' => 'time',
+                       'meta_value' => array( 1, 1000 ),
+                       'meta_type' => 'numeric',
+                       'meta_compare' => 'NOT BETWEEN'
+                       );
+
+               $query = new WP_Query( $args );
+               $this->assertEquals( 2, count ( $query->posts ) );
+               foreach ( $query->posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $query->posts, 'ID' );
+               $this->assertEqualSets( array( $post_id2, $post_id3 ), $posts );
+
+               $args = array(
+                       'meta_key' => 'time',
+                       'meta_value' => array( 1, 1000 ),
+                       'meta_type' => 'numeric',
+                       'meta_compare' => 'BETWEEN'
+                       );
+
+               $query = new WP_Query( $args );
+               $this->assertEquals( 3, count ( $query->posts ) );
+               foreach ( $query->posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $query->posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id4, $post_id5 ), $posts );
+       }
+
+       /**
+        * @ticket 16829
+        */
+       public function test_meta_default_compare() {
+               // compare should default to IN when meta_value is an array
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'foo', 'bar' );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'bar', 'baz' );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'foo', 'baz' );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'baz', 'bar' );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'foo', rand_str() );
+
+               $posts = get_posts( array(
+                       'meta_key' => 'foo',
+                       'meta_value' => array( 'bar', 'baz' )
+               ) );
+
+               $this->assertEquals( 2, count( $posts ) );
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id3 ), $posts );
+
+               $posts = get_posts( array(
+                       'meta_key' => 'foo',
+                       'meta_value' => array( 'bar', 'baz' ),
+                       'meta_compare' => 'IN'
+               ) );
+
+               $this->assertEquals( 2, count( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id3 ), $posts );
+       }
+
+       /**
+        * @ticket 17264
+        */
+       public function test_duplicate_posts_when_no_key() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'city', 'Lorem' );
+               add_post_meta( $post_id, 'address', '123 Lorem St.' );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'city', 'Lorem' );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'city', 'Loren' );
+
+               $args = array(
+                       'meta_query' => array(
+                       array(
+                               'value' => 'lorem',
+                               'compare' => 'LIKE'
+                       )
+                       )
+               );
+
+               $posts = get_posts( $args );
+               $this->assertEquals( 2, count( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id2 ), $posts );
+       }
+
+       /**
+        * @ticket 15292
+        */
+       public function test_empty_meta_value() {
+               $post_id = $this->factory->post->create();
+               add_post_meta( $post_id, 'foo', '0' );
+               add_post_meta( $post_id, 'bar', 0 );
+               $post_id2 = $this->factory->post->create();
+               add_post_meta( $post_id2, 'foo', 1 );
+               $post_id3 = $this->factory->post->create();
+               add_post_meta( $post_id3, 'baz', 0 );
+               $post_id4 = $this->factory->post->create();
+               add_post_meta( $post_id4, 'baz', 0 );
+               $post_id5 = $this->factory->post->create();
+               add_post_meta( $post_id5, 'baz', 0 );
+               add_post_meta( $post_id5, 'bar', '0' );
+               $post_id6 = $this->factory->post->create();
+               add_post_meta( $post_id6, 'baz', 0 );
+
+               $q = new WP_Query( array( 'meta_key' => 'foo', 'meta_value' => '0' ) );
+               $this->assertEquals( 1, count ( $q->posts ) );
+               foreach ( $q->posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $this->assertEquals( $post_id, $q->posts[0]->ID );
+
+               $posts = get_posts( array( 'meta_key' => 'bar', 'meta_value' => '0' ) );
+               $this->assertEquals( 2, count ( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id5 ), $posts );
+
+               $posts = get_posts( array( 'meta_key' => 'bar', 'meta_value' => 0 ) );
+               $this->assertEquals( 2, count ( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id5 ), $posts );
+
+               $posts = get_posts( array( 'meta_value' => 0 ) );
+               $this->assertEquals( 5, count ( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts );
+
+               $posts = get_posts( array( 'meta_value' => '0' ) );
+               $this->assertEquals( 5, count ( $posts ) );
+               foreach ( $posts as $post ) {
+                       $this->assertInstanceOf( 'WP_Post', $post );
+                       $this->assertEquals( 'raw', $post->filter );
+               }
+               $posts = wp_list_pluck( $posts, 'ID' );
+               $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts );
+       }
+}
</ins></span></pre></div>
<a id="trunktestsphpunittestsquerytaxQueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/query/taxQuery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/query/taxQuery.php      2015-01-26 19:03:09 UTC (rev 31285)
+++ trunk/tests/phpunit/tests/query/taxQuery.php        2015-01-27 20:03:50 UTC (rev 31286)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,282 +1,1308 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Test the is_*() functions in query.php across the URL structure
- *
- * This exercises both query.php and rewrite.php: urls are fed through the rewrite code,
- * then we test the effects of each url on the wp_query object.
- *
</del><span class="cx" style="display: block; padding: 0 10px">  * @group query
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @group rewrite
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group taxonomy
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Query_TaxQuery extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        protected $tag_id;
-       protected $cat_id;
-       protected $tax_id;
-       protected $tax_id2;
-       protected $post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_field_slug() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        protected $cat;
-       protected $uncat;
-       protected $tag;
-       protected $tax;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_set_post_terms( $p1, $t, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function setUp() {
-               global $wp_rewrite;
-               parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                               ),
+                       ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                set_current_screen( 'front' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $p1 ), $q->posts );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $GLOBALS['wp_the_query'] = new WP_Query();
-               $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_field_name() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $wp_rewrite->init();
-               $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_set_post_terms( $p1, $t, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                create_initial_taxonomies();
-               register_taxonomy( 'testtax', 'post', array( 'public' => true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'Foo' ),
+                                       'field' => 'name',
+                               ),
+                       ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $wp_rewrite->flush_rules();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $p1 ), $q->posts );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->tag_id = $this->factory->tag->create( array( 'slug' => 'tag-slug' ) );
-               $this->cat_id = $this->factory->category->create( array( 'slug' => 'cat-slug' ) );
-               $this->tax_id = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug' ) );
-               $this->tax_id2 = $this->factory->term->create( array( 'taxonomy' => 'testtax', 'slug' => 'tax-slug2' ) );
-               $this->post_id = $this->factory->post->create();
-               wp_set_object_terms( $this->post_id, $this->cat_id, 'category' );
-               wp_set_object_terms( $this->post_id, array( $this->tax_id, $this->tax_id2 ), 'testtax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_field_term_taxonomy_id() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->cat = get_term( $this->cat_id, 'category' );
-               _make_cat_compat( $this->cat );
-               $this->tag = get_term( $this->tag_id, 'post_tag' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tt_ids = wp_set_post_terms( $p1, $t, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->uncat = get_term_by( 'slug', 'uncategorized', 'category' );
-               _make_cat_compat( $this->uncat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => $tt_ids,
+                                       'field' => 'term_taxonomy_id',
+                               ),
+                       ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $p1 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function tearDown() {
-               global $wp_rewrite;
-               parent::tearDown();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_field_term_id() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                _unregister_taxonomy( 'testtax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_set_post_terms( $p1, $t, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $wp_rewrite->init();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( $t ),
+                                       'field' => 'term_id',
+                               ),
+                       ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $p1 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tag_action_tax() {
-               // tag with tax added
-               $this->go_to( home_url( "/tag/tag-slug/" ) );
-               $this->assertQueryTrue( 'is_tag', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
-               $this->assertEquals( get_queried_object(), $this->tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_operator_in() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               wp_set_post_terms( $p1, $t, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                                       'operator' => 'IN',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p1 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tag_query_cat_action_tax() {
-               // tag + category with tax added
-               $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id" ) );
-               $this->assertQueryTrue( 'is_category', 'is_tag', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertNotEmpty( get_query_var( 'cat' ) );
-               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
-               $this->assertEquals( get_queried_object(), $this->cat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_operator_not_in() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               wp_set_post_terms( $p1, $t, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                                       'operator' => 'NOT IN',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tag_query_cat_query_tax_action_tax() {
-               // tag + category + tax with tax added
-               $this->go_to( home_url( "/tag/tag-slug/?cat=$this->cat_id&testtax=tax-slug2" ) );
-               $this->assertQueryTrue( 'is_category', 'is_tag', 'is_tax', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertNotEmpty( get_query_var( 'cat' ) );
-               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
-               $this->assertNotEmpty( get_query_var( 'testtax' ) );
-               $this->assertEquals( get_queried_object(), $this->cat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_single_term_operator_and() {
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+
+               wp_set_post_terms( $p1, $t, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                                       'operator' => 'AND',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p1 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_cat_action_tax() {
-               // category with tax added
-               $this->go_to( home_url( "/category/cat-slug/" ) );
-               $this->assertQueryTrue( 'is_category', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'cat' ) );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertEquals( get_queried_object(), $this->cat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_multiple_terms_operator_in() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_post_terms( $p1, $t1, 'category' );
+               wp_set_post_terms( $p2, $t2, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo', 'bar' ),
+                                       'field' => 'slug',
+                                       'operator' => 'IN',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public function test_tax_query_single_query_multiple_terms_operator_not_in() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_post_terms( $p1, $t1, 'category' );
+               wp_set_post_terms( $p2, $t2, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo', 'bar' ),
+                                       'field' => 'slug',
+                                       'operator' => 'NOT IN',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p3 ), $q->posts );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 26627
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 18105
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_cat_uncat_action_tax() {
-               // category with tax added
-               add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_multiple_queries_operator_not_in() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->go_to( home_url( "/category/uncategorized/" ) );
-               $this->assertQueryTrue( 'is_category', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'cat' ) );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertEquals( get_queried_object(), $this->uncat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         wp_set_post_terms( $p1, $t1, 'category' );
+               wp_set_post_terms( $p2, $t2, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                remove_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'AND',
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                                       'operator' => 'NOT IN',
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'bar' ),
+                                       'field' => 'slug',
+                                       'operator' => 'NOT IN',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p3 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function _cat_uncat_action_tax( &$query ) {
-               $this->assertTrue( $query->is_category() );
-               $this->assertTrue( $query->is_archive() );
-               $this->assertNotEmpty( $query->get( 'category_name' ) );
-               $this->assertNotEmpty( $query->get( 'tax_query' ) );
-               $this->assertEquals( $query->get_queried_object(), $this->uncat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_single_query_multiple_terms_operator_and() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, $t1, 'category' );
+               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo', 'bar' ),
+                                       'field' => 'slug',
+                                       'operator' => 'AND',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @ticket 26728
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 29181
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tax_action_tax() {
-               // tax with tax added
-               $this->go_to( home_url( '/testtax/tax-slug2/' ) );
-               $this->assertQueryTrue( 'is_tax', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertEquals( get_queried_object(), get_term( $this->tax_id, 'testtax' ) );
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_operator_not_exists() {
+               register_taxonomy( 'wptests_tax1', 'post' );
+               register_taxonomy( 'wptests_tax2', 'post' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tax_query_tag_action_tax() {
-               // tax + tag with tax added
-               $this->go_to( home_url( "/testtax/tax-slug2/?tag_id=$this->tag_id" ) );
-               $this->assertQueryTrue( 'is_tag', 'is_tax', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertNotEmpty( get_query_var( 'tag_id' ) );
-               $this->assertEquals( get_queried_object(), $this->tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
+               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
+               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'wptests_tax2',
+                                       'operator' => 'NOT EXISTS',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $p1, $p3 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_tax_query_cat_action_tax() {
-               // tax + cat with tax added
-               $this->go_to( home_url( "/testtax/tax-slug2/?cat=$this->cat_id" ) );
-               $this->assertQueryTrue( 'is_category', 'is_tax', 'is_archive' );
-               $this->assertNotEmpty( get_query_var( 'tax_query' ) );
-               $this->assertNotEmpty( get_query_var( 'taxonomy' ) );
-               $this->assertNotEmpty( get_query_var( 'term_id' ) );
-               $this->assertNotEmpty( get_query_var( 'cat' ) );
-               $this->assertEquals( get_queried_object(), $this->cat );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @ticket 29181
+        */
+       public function test_tax_query_operator_exists() {
+               register_taxonomy( 'wptests_tax1', 'post' );
+               register_taxonomy( 'wptests_tax2', 'post' );
+
+               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
+               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
+               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'wptests_tax2',
+                                       'operator' => 'EXISTS',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function pre_get_posts_tax_category_tax_query( &$query ) {
-               $query->set( 'tax_query', array(
-                       array( 'taxonomy' => 'testtax', 'field' => 'term_id', 'terms' => $this->tax_id )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @ticket 29181
+        */
+       public function test_tax_query_operator_exists_should_ignore_terms() {
+               register_taxonomy( 'wptests_tax1', 'post' );
+               register_taxonomy( 'wptests_tax2', 'post' );
+
+               $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
+               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
+               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'wptests_tax2',
+                                       'operator' => 'EXISTS',
+                                       'terms' => array( 'foo', 'bar' ),
+                               ),
+                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               $this->assertEqualSets( array( $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group 30623
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 29181
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_term_id_should_return_term_object() {
-               // Don't override the args provided below.
-               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_operator_exists_with_no_taxonomy() {
+               register_taxonomy( 'wptests_tax1', 'post' );
+               register_taxonomy( 'wptests_tax2', 'post' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $args = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $t1 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax1' ) );
+               $t2 = $this->factory->term->create( array( 'taxonomy' => 'wptests_tax2' ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $t1 ), 'wptests_tax1' );
+               wp_set_object_terms( $p2, array( $t2 ), 'wptests_tax2' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
</ins><span class="cx" style="display: block; padding: 0 10px">                         'tax_query' => array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                array(
+                                       'operator' => 'EXISTS',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEmpty( $q->posts );
+       }
+
+       public function test_tax_query_multiple_queries_relation_and() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, $t1, 'category' );
+               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'taxonomy' => 'testtax',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'bar' ),
+                                       'field' => 'slug',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( array( $p2 ), $q->posts );
+       }
+
+       public function test_tax_query_multiple_queries_relation_or() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, $t1, 'category' );
+               wp_set_object_terms( $p2, array( $t1, $t2 ), 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'bar' ),
+                                       'field' => 'slug',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
+       }
+
+       public function test_tax_query_multiple_queries_different_taxonomies() {
+               $t1 = $this->factory->term->create( array(
+                       'taxonomy' => 'post_tag',
+                       'slug' => 'foo',
+                       'name' => 'Foo',
+               ) );
+               $t2 = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+                       'name' => 'Bar',
+               ) );
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, $t1, 'post_tag' );
+               wp_set_object_terms( $p2, $t2, 'category' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'terms' => array( 'foo' ),
+                                       'field' => 'slug',
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( 'bar' ),
+                                       'field' => 'slug',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
+       }
+
+       /**
+        * @ticket 29738
+        */
+       public function test_tax_query_two_nested_queries() {
+               register_taxonomy( 'foo', 'post' );
+               register_taxonomy( 'bar', 'post' );
+
+               $foo_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $foo_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $bar_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+               $bar_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
+               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
+               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
+               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'relation' => 'AND',
+                                       array(
+                                               'taxonomy' => 'foo',
+                                               'terms' => array( $foo_term_1 ),
+                                               'field' => 'term_id',
+                                       ),
+                                       array(
+                                               'taxonomy' => 'bar',
+                                               'terms' => array( $bar_term_1 ),
+                                               'field' => 'term_id',
+                                       ),
+                               ),
+                               array(
+                                       'relation' => 'AND',
+                                       array(
+                                               'taxonomy' => 'foo',
+                                               'terms' => array( $foo_term_2 ),
+                                               'field' => 'term_id',
+                                       ),
+                                       array(
+                                               'taxonomy' => 'bar',
+                                               'terms' => array( $bar_term_2 ),
+                                               'field' => 'term_id',
+                                       ),
+                               ),
+                       ),
+               ) );
+
+               _unregister_taxonomy( 'foo' );
+               _unregister_taxonomy( 'bar' );
+
+               $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
+       }
+
+       /**
+        * @ticket 29738
+        */
+       public function test_tax_query_one_nested_query_one_first_order_query() {
+               register_taxonomy( 'foo', 'post' );
+               register_taxonomy( 'bar', 'post' );
+
+               $foo_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $foo_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $bar_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+               $bar_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
+               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
+               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
+               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $foo_term_2 ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'field' => 'term_id',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'terms' => array(
-                                               $this->tax_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         ),
+                               array(
+                                       'relation' => 'AND',
+                                       array(
+                                               'taxonomy' => 'foo',
+                                               'terms' => array( $foo_term_1 ),
+                                               'field' => 'term_id',
</ins><span class="cx" style="display: block; padding: 0 10px">                                         ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        array(
+                                               'taxonomy' => 'bar',
+                                               'terms' => array( $bar_term_1 ),
+                                               'field' => 'term_id',
+                                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $q = new WP_Query( $args );
-               $object = $q->get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         _unregister_taxonomy( 'foo' );
+               _unregister_taxonomy( 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = get_term( $this->tax_id, 'testtax' );
-
-               $this->assertEquals( $expected, $object );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $p1, $p2 ), $q->posts );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group 30623
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 29738
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_get_queried_object_with_custom_taxonomy_tax_query_and_field_slug_should_return_term_object() {
-               // Don't override the args provided below.
-               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_one_double_nested_query_one_first_order_query() {
+               register_taxonomy( 'foo', 'post' );
+               register_taxonomy( 'bar', 'post' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $args = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $foo_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $foo_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $bar_term_1 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+               $bar_term_2 = $this->factory->term->create( array(
+                       'taxonomy' => 'bar',
+               ) );
+
+               $p1 = $this->factory->post->create();
+               $p2 = $this->factory->post->create();
+               $p3 = $this->factory->post->create();
+               $p4 = $this->factory->post->create();
+
+               wp_set_object_terms( $p1, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p1, array( $bar_term_1 ), 'bar' );
+               wp_set_object_terms( $p2, array( $foo_term_2 ), 'foo' );
+               wp_set_object_terms( $p2, array( $bar_term_2 ), 'bar' );
+               wp_set_object_terms( $p3, array( $foo_term_1 ), 'foo' );
+               wp_set_object_terms( $p3, array( $bar_term_2 ), 'bar' );
+
+               $q = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'tax_query' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'relation' => 'AND',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'relation' => 'OR',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'taxonomy' => 'testtax',
-                                       'field' => 'slug',
-                                       'terms' => array(
-                                               'tax-slug',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'taxonomy' => 'foo',
+                                       'terms' => array( $foo_term_2 ),
+                                       'field' => 'term_id',
+                               ),
+                               array(
+                                       'relation' => 'AND',
+                                       array(
+                                               'taxonomy' => 'foo',
+                                               'terms' => array( $foo_term_1 ),
+                                               'field' => 'term_id',
</ins><span class="cx" style="display: block; padding: 0 10px">                                         ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        array(
+                                               'relation' => 'OR',
+                                               array(
+                                                       'taxonomy' => 'bar',
+                                                       'terms' => array( $bar_term_1 ),
+                                                       'field' => 'term_id',
+                                               ),
+                                               array(
+                                                       'taxonomy' => 'bar',
+                                                       'terms' => array( $bar_term_2 ),
+                                                       'field' => 'term_id',
+                                               ),
+                                       ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $q = new WP_Query( $args );
-               $object = $q->get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         _unregister_taxonomy( 'foo' );
+               _unregister_taxonomy( 'bar' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = get_term( $this->tax_id, 'testtax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEqualSets( array( $p1, $p2, $p3 ), $q->posts );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Only compare term_id because object_id may or may not be part of either value.
-               $this->assertEquals( $expected->term_id, $object->term_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @ticket 20604
+        */
+       public function test_tax_query_relation_or_both_clauses_empty_terms() {
+               // An empty tax query should return an empty array, not all posts.
+
+               $this->factory->post->create_many( 10 );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_term_cache' => false,
+                       'update_post_meta_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'field' => 'id',
+                                       'terms' => false,
+                                       'operator' => 'IN'
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => false,
+                                       'operator' => 'IN'
+                               ),
+                       )
+               ) );
+
+               $posts = $query->get_posts();
+               $this->assertEquals( 0 , count( $posts ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @group 30623
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @ticket 20604
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_get_queried_object_with_custom_taxonomy_tax_query_with_multiple_clauses_should_return_term_object_corresponding_to_the_first_queried_tax() {
-               // Don't override the args provided below.
-               remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_tax_query_relation_or_one_clause_empty_terms() {
+               // An empty tax query should return an empty array, not all posts.
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                register_taxonomy( 'testtax2', 'post' );
-               $testtax2_term_id = $this->factory->term->create( array(
-                       'taxonomy' => 'testtax2',
-                       'slug' => 'testtax2-slug',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->factory->post->create_many( 10 );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_term_cache' => false,
+                       'update_post_meta_cache' => false,
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'field' => 'id',
+                                       'terms' => array( 'foo' ),
+                                       'operator' => 'IN'
+                               ),
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => false,
+                                       'operator' => 'IN'
+                               ),
+                       )
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $args = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $posts = $query->get_posts();
+               $this->assertEquals( 0 , count( $posts ) );
+       }
+
+       public function test_tax_query_include_children() {
+               $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
+               $cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
+               $cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
+               $cat_d = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'West Syndney', 'parent' => $cat_b ) );
+
+               $post_a = $this->factory->post->create( array( 'post_category' => array( $cat_a ) ) );
+               $post_b = $this->factory->post->create( array( 'post_category' => array( $cat_b ) ) );
+               $post_c = $this->factory->post->create( array( 'post_category' => array( $cat_c ) ) );
+               $post_d = $this->factory->post->create( array( 'post_category' => array( $cat_d ) ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
</ins><span class="cx" style="display: block; padding: 0 10px">                         'tax_query' => array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_a ),
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 4 , count( $posts ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_a ),
+                                       'include_children' => false
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 1 , count( $posts ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_b ),
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 3 , count( $posts ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_b ),
+                                       'include_children' => false
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 1 , count( $posts ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_c ),
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 1 , count( $posts ) );
+
+               $posts = get_posts( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'id',
+                                       'terms' => array( $cat_c ),
+                                       'include_children' => false
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( 1 , count( $posts ) );
+       }
+
+       public function test_tax_query_taxonomy_with_attachments() {
+               $q = new WP_Query();
+
+               register_taxonomy_for_object_type( 'post_tag', 'attachment:image' );
+               $tag_id = $this->factory->term->create( array( 'slug' => rand_str(), 'name' => rand_str() ) );
+               $image_id = $this->factory->attachment->create_object( 'image.jpg', 0, array(
+                       'post_mime_type' => 'image/jpeg',
+                       'post_type' => 'attachment'
+               ) );
+               wp_set_object_terms( $image_id, $tag_id, 'post_tag' );
+
+               $posts = $q->query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'post_type' => 'attachment',
+                       'post_status' => 'inherit',
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'field' => 'term_id',
+                                       'terms' => array( $tag_id )
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( array( $image_id ), $posts );
+       }
+
+       public function test_tax_query_no_taxonomy() {
+               $cat_id = $this->factory->category->create( array( 'name' => 'alpha' ) );
+               $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
+
+               $response1 = new WP_Query( array(
+                       'tax_query' => array(
+                               array( 'terms' => array( $cat_id ) )
+                       )
+               ) );
+               $this->assertEmpty( $response1->posts );
+
+               $response2 = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( $cat_id )
+                               )
+                       )
+               ) );
+               $this->assertNotEmpty( $response2->posts );
+
+               $term = get_category( $cat_id );
+               $response3 = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               array(
+                                       'field' => 'term_taxonomy_id',
+                                       'terms' => array( $term->term_taxonomy_id )
+                               )
+                       )
+               ) );
+               $this->assertNotEmpty( $response3->posts );
+       }
+
+       public function test_term_taxonomy_id_field_no_taxonomy() {
+               $q = new WP_Query();
+
+               $posts = $this->factory->post->create_many( 5 );
+
+               $cats = $tags = array();
+
+               // need term_taxonomy_ids in addition to term_ids, so no factory
+               for ( $i = 0; $i < 5; $i++ ) {
+                       $cats[$i] = wp_insert_term( 'category-' . $i , 'category' );
+                       $tags[$i] = wp_insert_term( 'tag-' . $i, 'post_tag' );
+
+                       // post 0 gets all terms
+                       wp_set_object_terms( $posts[0], array( $cats[$i]['term_id'] ), 'category', true );
+                       wp_set_object_terms( $posts[0], array( $tags[$i]['term_id'] ), 'post_tag', true );
+               }
+
+               wp_set_object_terms( $posts[1], array( $cats[0]['term_id'], $cats[2]['term_id'], $cats[4]['term_id'] ), 'category' );
+               wp_set_object_terms( $posts[1], array( $tags[0]['term_id'], $tags[2]['term_id'], $cats[4]['term_id'] ), 'post_tag' );
+
+               wp_set_object_terms( $posts[2], array( $cats[1]['term_id'], $cats[3]['term_id'] ), 'category' );
+               wp_set_object_terms( $posts[2], array( $tags[1]['term_id'], $tags[3]['term_id'] ), 'post_tag' );
+
+               wp_set_object_terms( $posts[3], array( $cats[0]['term_id'], $cats[2]['term_id'], $cats[4]['term_id'] ), 'category' );
+               wp_set_object_terms( $posts[3], array( $tags[1]['term_id'], $tags[3]['term_id'] ), 'post_tag' );
+
+               $results1 = $q->query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
+                       'tax_query' => array(
+                               'relation' => 'OR',
+                               array(
+                                       'field' => 'term_taxonomy_id',
+                                       'terms' => array( $cats[0]['term_taxonomy_id'], $cats[2]['term_taxonomy_id'], $cats[4]['term_taxonomy_id'], $tags[0]['term_taxonomy_id'], $tags[2]['term_taxonomy_id'], $cats[4]['term_taxonomy_id'] ),
+                                       'operator' => 'AND',
+                                       'include_children' => false,
+                               ),
+                               array(
+                                       'field' => 'term_taxonomy_id',
+                                       'terms' => array( $cats[1]['term_taxonomy_id'], $cats[3]['term_taxonomy_id'], $tags[1]['term_taxonomy_id'], $tags[3]['term_taxonomy_id'] ),
+                                       'operator' => 'AND',
+                                       'include_children' => false,
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( array( $posts[0], $posts[1], $posts[2] ), $results1, 'Relation: OR; Operator: AND' );
+
+               $results2 = $q->query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'orderby' => 'ID',
+                       'order' => 'ASC',
+                       'tax_query' => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                 'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'taxonomy' => 'testtax',
-                                       'field' => 'slug',
-                                       'terms' => array(
-                                               'tax-slug',
-                                       ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'field' => 'term_taxonomy_id',
+                                       'terms' => array( $cats[0]['term_taxonomy_id'], $tags[0]['term_taxonomy_id'] ),
+                                       'operator' => 'IN',
+                                       'include_children' => false,
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'taxonomy' => 'testtax2',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'field' => 'term_taxonomy_id',
+                                       'terms' => array( $cats[3]['term_taxonomy_id'], $tags[3]['term_taxonomy_id'] ),
+                                       'operator' => 'IN',
+                                       'include_children' => false,
+                               )
+                       )
+               ) );
+
+               $this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' );
+       }
+
+       /**
+        * @ticket 29738
+        */
+       public function test_populate_taxonomy_query_var_from_tax_query() {
+               register_taxonomy( 'foo', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $c = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+               ) );
+
+               $q = new WP_Query( array(
+                       'tax_query' => array(
+                               // Empty terms mean that this one should be skipped
+                               array(
+                                       'taxonomy' => 'bar',
+                                       'terms' => array(),
+                               ),
+
+                               // Category and post tags should be skipped
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( $c ),
+                               ),
+
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $t ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertSame( 'foo', $q->get( 'taxonomy' ) );
+
+               _unregister_taxonomy( 'foo' );
+       }
+
+       public function test_populate_taxonomy_query_var_from_tax_query_taxonomy_already_set() {
+               register_taxonomy( 'foo', 'post' );
+               register_taxonomy( 'foo1', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+
+               $q = new WP_Query( array(
+                       'taxonomy' => 'bar',
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $t ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertSame( 'bar', $q->get( 'taxonomy' ) );
+
+               _unregister_taxonomy( 'foo' );
+               _unregister_taxonomy( 'foo1' );
+       }
+
+       public function test_populate_term_query_var_from_tax_query() {
+               register_taxonomy( 'foo', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+                       'slug' => 'bar',
+               ) );
+
+               $q = new WP_Query( array(
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( 'bar' ),
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'field' => 'slug',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'terms' => array(
-                                               'testtax2-slug',
-                                       ),
</del><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        )
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $q = new WP_Query( $args );
-               $object = $q->get_queried_object();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'bar', $q->get( 'term' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = get_term( $this->tax_id, 'testtax' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         _unregister_taxonomy( 'foo' );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Only compare term_id because object_id may or may not be part of either value.
-               $this->assertEquals( $expected->term_id, $object->term_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_populate_term_id_query_var_from_tax_query() {
+               register_taxonomy( 'foo', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+                       'slug' => 'bar',
+               ) );
+
+               $q = new WP_Query( array(
+                       'tax_query' => array(
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $t ),
+                                       'field' => 'term_id',
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( $t, $q->get( 'term_id' ) );
+
+               _unregister_taxonomy( 'foo' );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * @ticket 29738
+        */
+       public function test_populate_cat_category_name_query_var_from_tax_query() {
+               register_taxonomy( 'foo', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $c = $this->factory->term->create( array(
+                       'taxonomy' => 'category',
+                       'slug' => 'bar',
+               ) );
+
+               $q = new WP_Query( array(
+                       'tax_query' => array(
+                               // Non-category should be skipped
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $t ),
+                               ),
+
+                               // Empty terms mean that this one should be skipped
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array(),
+                               ),
+
+                               // Category and post tags should be skipped
+                               array(
+                                       'taxonomy' => 'category',
+                                       'terms' => array( $c ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( $c, $q->get( 'cat' ) );
+               $this->assertEquals( 'bar', $q->get( 'category_name' ) );
+
+               _unregister_taxonomy( 'foo' );
+       }
+
+       /**
+        * @ticket 29738
+        */
+       public function test_populate_tag_id_query_var_from_tax_query() {
+               register_taxonomy( 'foo', 'post' );
+               $t = $this->factory->term->create( array(
+                       'taxonomy' => 'foo',
+               ) );
+               $tag = $this->factory->term->create( array(
+                       'taxonomy' => 'post_tag',
+                       'slug' => 'bar',
+               ) );
+
+               $q = new WP_Query( array(
+                       'tax_query' => array(
+                               // Non-tag should be skipped
+                               array(
+                                       'taxonomy' => 'foo',
+                                       'terms' => array( $t ),
+                               ),
+
+                               // Empty terms mean that this one should be skipped
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'terms' => array(),
+                               ),
+
+                               // Category and post tags should be skipped
+                               array(
+                                       'taxonomy' => 'post_tag',
+                                       'terms' => array( $tag ),
+                               ),
+                       ),
+               ) );
+
+               $this->assertEquals( $tag, $q->get( 'tag_id' ) );
+
+               _unregister_taxonomy( 'foo' );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>