<!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>[29805] trunk/tests/phpunit/tests: Improve unit tests for WP_Tax_Query.</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/29805">29805</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/29805","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>2014-10-02 01:07:20 +0000 (Thu, 02 Oct 2014)</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 unit tests for WP_Tax_Query.

* Exhaustive tests for publicly available functionality of WP_Tax_Query.
* For tests that are related to the tax_query argument as used in WP_Query, move to tests/post/query.php.
* Add some tax_query tests to cover single vs multiple queries using AND and OR; various values for 'field'; various values for 'operator'.
* Improve test names.
* Correct @group annotations.
* Improve performance of some WP_Query-related tests by declaring 'update_post_meta/term_cache' false.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestspostqueryphp">trunk/tests/phpunit/tests/post/query.php</a></li>
<li><a href="#trunktestsphpunitteststermqueryphp">trunk/tests/phpunit/tests/term/query.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  2014-10-02 00:55:40 UTC (rev 29804)
+++ trunk/tests/phpunit/tests/post/query.php    2014-10-02 01:07:20 UTC (rev 29805)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -772,37 +772,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEqualSets( array( $post_4, $post_3, $post_2, $post_1 ), $query->posts );
</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 20604
-        */
-       function test_taxonomy_empty_or() {
-               // 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',
-                       '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 ) );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         function test_meta_between_not_between() {
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id = $this->factory->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                add_post_meta( $post_id, 'time', 500 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -983,7 +952,534 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts );
</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">-        function test_taxonomy_include_children() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * @group taxonomy
+        */
+       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->assertEquals( 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
+        */
+       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 );
+       }
+
+       /**
+        * @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->assertEquals( 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->assertEquals( array( $p1, $p2 ), $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() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Australia' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'Sydney', 'parent' => $cat_a ) );
</span><span class="cx" style="display: block; padding: 0 10px">                $cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'East Syndney', 'parent' => $cat_b ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -995,6 +1491,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $post_d = $this->factory->post->create( array( 'post_category' => array( $cat_d ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1007,6 +1506,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 4 , count( $posts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1020,6 +1522,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 1 , count( $posts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1032,6 +1537,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 3 , count( $posts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1045,6 +1553,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 1 , count( $posts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1057,6 +1568,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 1 , count( $posts ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $posts = get_posts( array(
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        '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><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'taxonomy' => 'category',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1071,6 +1585,458 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @group taxonomy
+        */
+       function test_category__and_var() {
+               $q = new WP_Query();
+
+               $term_id = $this->factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
+               $term_id2 = $this->factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
+               $post_id = $this->factory->post->create();
+
+               wp_set_post_categories( $post_id, $term_id );
+
+               $posts = $q->query( array( 'category__and' => array( $term_id ) ) );
+
+               $this->assertEmpty( $q->get( 'category__and' ) );
+               $this->assertCount( 0, $q->get( 'category__and' ) );
+               $this->assertNotEmpty( $q->get( 'category__in' ) );
+               $this->assertCount( 1, $q->get( 'category__in' ) );
+
+               $this->assertNotEmpty( $posts );
+               $this->assertEquals( array( $post_id ), wp_list_pluck( $posts, 'ID' ) );
+
+               $posts2 = $q->query( array( 'category__and' => array( $term_id, $term_id2 ) ) );
+               $this->assertNotEmpty( $q->get( 'category__and' ) );
+               $this->assertCount( 2, $q->get( 'category__and' ) );
+               $this->assertEmpty( $q->get( 'category__in' ) );
+               $this->assertCount( 0, $q->get( 'category__in' ) );
+
+               $this->assertEmpty( $posts2 );
+       }
+
+       /**
+        * @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 );
+       }
+
+       /**
+        * @ticket 27193
+        * @group taxonomy
+        */
+       function test_cat_or_tag() {
+               $category1 = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'alpha' ) );
+               $category2 = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'beta' ) );
+
+               $tag1 = $this->factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'gamma' ) );
+               $tag2 = $this->factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'delta' ) );
+
+               $post_id1 = $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $category1 ) ) );
+               $terms1 = get_the_category( $post_id1 );
+               $this->assertEquals( array( get_category( $category1 ) ), $terms1 );
+
+               $post_id2 = $this->factory->post->create( array( 'post_title' => 'beta', 'post_category' => array( $category2 ) ) );
+               $terms2 = get_the_category( $post_id2 );
+               $this->assertEquals( array( get_category( $category2 ) ), $terms2 );
+
+               $post_id3 = $this->factory->post->create( array( 'post_title' => 'gamma', 'post_tag' => array( $tag1 ) ) );
+               $post_id4 = $this->factory->post->create( array( 'post_title' => 'delta', 'post_tag' => array( $tag2 ) ) );
+
+               $query = new WP_Query( array(
+                       'fields' => 'ids',
+                       'update_post_meta_cache' => false,
+                       'update_post_term_cache' => false,
+                       'tax_query' => array(
+                               //'relation' => 'OR',
+                               array(
+                                       'taxonomy' => 'category',
+                                       'field' => 'term_id',
+                                       'terms' => array( $category1, $category2 )
+                               )
+                       )
+               ) );
+               $ids = $query->get_posts();
+               $this->assertEquals( array( $post_id1, $post_id2 ), $ids );
+       }
+
+       /**
+        * @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' );
+       }
+
+       /**
+        * @ticket 28099
+        * @group taxonomy
+        */
+       function test_empty_category__in() {
+               $cat_id = $this->factory->category->create();
+               $post_id = $this->factory->post->create();
+               wp_set_post_categories( $post_id, $cat_id );
+
+               $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) );
+               $this->assertNotEmpty( $q1 );
+               $q2 = get_posts( array( 'category__in' => array() ) );
+               $this->assertNotEmpty( $q2 );
+
+               $tag = wp_insert_term( 'woo', 'post_tag' );
+               $tag_id = $tag['term_id'];
+               $slug = get_tag( $tag_id )->slug;
+               wp_set_post_tags( $post_id, $slug );
+
+               $q3 = get_posts( array( 'tag__in' => array( $tag_id ) ) );
+               $this->assertNotEmpty( $q3 );
+               $q4 = get_posts( array( 'tag__in' => array() ) );
+               $this->assertNotEmpty( $q4 );
+
+               $q5 = get_posts( array( 'tag_slug__in' => array( $slug ) ) );
+               $this->assertNotEmpty( $q5 );
+               $q6 = get_posts( array( 'tag_slug__in' => array() ) );
+               $this->assertNotEmpty( $q6 );
+       }
+
+       /**
+        * @group taxonomy
+        * @ticket 29718
+        */
+       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 29718
+        */
+       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' => 'foo',
+                       '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 29718
+        */
+       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">          * @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="trunktestsphpunitteststermqueryphp"></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/term/query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/query.php  2014-10-02 00:55:40 UTC (rev 29804)
+++ trunk/tests/phpunit/tests/term/query.php    2014-10-02 01:07:20 UTC (rev 29805)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,229 +6,216 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Tax_Query extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">        protected $q;
</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 setUp() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function setUp() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px">                unset( $this->q );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->q = new WP_Query();
</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">-        function test_category__and_var() {
-               $term_id = $this->factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
-               $term_id2 = $this->factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
-               $post_id = $this->factory->post->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_with_relation_default() {
+               $tq = new WP_Tax_Query( array() );
+               $this->assertSame( 'AND', $tq->relation );
+       }
</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_set_post_categories( $post_id, $term_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_with_relation_or_lowercase() {
+               $tq = new WP_Tax_Query( array(
+                       'relation' => 'or',
+               ) );
+               $this->assertSame( 'OR', $tq->relation );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $this->q->query( array( 'category__and' => array( $term_id ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_with_relation_or_uppercase() {
+               $tq = new WP_Tax_Query( array(
+                       'relation' => 'OR',
+               ) );
+               $this->assertSame( 'OR', $tq->relation );
+       }
</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->assertEmpty( $this->q->get( 'category__and' ) );
-               $this->assertCount( 0, $this->q->get( 'category__and' ) );
-               $this->assertNotEmpty( $this->q->get( 'category__in' ) );
-               $this->assertCount( 1, $this->q->get( 'category__in' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_with_relation_other() {
+               $tq = new WP_Tax_Query( array(
+                       'relation' => 'foo',
+               ) );
+               $this->assertSame( 'AND', $tq->relation );
+       }
</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->assertNotEmpty( $posts );
-               $this->assertEquals( array( $post_id ), wp_list_pluck( $posts, 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_fill_missing_query_params() {
+               $tq = new WP_Tax_Query( array(
+                       array(),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts2 = $this->q->query( array( 'category__and' => array( $term_id, $term_id2 ) ) );
-               $this->assertNotEmpty( $this->q->get( 'category__and' ) );
-               $this->assertCount( 2, $this->q->get( 'category__and' ) );
-               $this->assertEmpty( $this->q->get( 'category__in' ) );
-               $this->assertCount( 0, $this->q->get( 'category__in' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array(
+                       'taxonomy' => '',
+                       'terms' => array(),
+                       'include_children' => true,
+                       'field' => 'term_id',
+                       'operator' => 'IN',
+               );
</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->assertEmpty( $posts2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $expected, $tq->queries[0] );
</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_taxonomy_with_attachments() {
-               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'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_construct_fill_missing_query_params_merge_with_passed_values() {
+               $tq = new WP_Tax_Query( array(
+                       array(
+                               'taxonomy' => 'foo',
+                               'include_children' => false,
+                               'foo' => '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">-                wp_set_object_terms( $image_id, $tag_id, 'post_tag' );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts = $this->q->query( array(
-                       'fields' => 'ids',
-                       'post_type' => 'attachment',
-                       'post_status' => 'inherit',
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'post_tag',
-                                       'field' => 'term_id',
-                                       'terms' => array( $tag_id )
-                               )
-                       )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $expected = array(
+                       'taxonomy' => 'foo',
+                       'terms' => array(),
+                       'include_children' => false,
+                       'field' => 'term_id',
+                       'operator' => 'IN',
+                       'foo' => 'bar',
+               );
+
+               $this->assertEquals( $expected, $tq->queries[0] );
+       }
+
+       public function test_construct_cast_terms_to_array() {
+               $tq = new WP_Tax_Query( array(
+                       array(
+                               'terms' => 'foo',
+                       ),
</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">-                $this->assertEquals( array( $image_id ), $posts );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( 'foo', ), $tq->queries[0]['terms'] );
</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">-        /**
-        * @ticket 27193
-        */
-       function test_cat_or_tag() {
-               $category1 = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'alpha' ) );
-               $category2 = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'beta' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_terms_empty() {
+               $tq = new WP_Tax_Query( array(
+                       array(),
+               ) );
+               $query = $tq->queries[0];
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $tag1 = $this->factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'gamma' ) );
-               $tag2 = $this->factory->term->create( array( 'taxonomy' => 'post_tag', 'name' => 'delta' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq->transform_query( $tq->queries[0], '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">-                $post_id1 = $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $category1 ) ) );
-               $terms1 = get_the_category( $post_id1 );
-               $this->assertEquals( array( get_category( $category1 ) ), $terms1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $query, $tq->queries[0] );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $post_id2 = $this->factory->post->create( array( 'post_title' => 'beta', 'post_category' => array( $category2 ) ) );
-               $terms2 = get_the_category( $post_id2 );
-               $this->assertEquals( array( get_category( $category2 ) ), $terms2 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_field_same_as_resulting_field() {
+               $tq = new WP_Tax_Query( array(
+                       array(
+                               'field' => 'term_id',
+                       ),
+               ) );
+               $query = $tq->queries[0];
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $post_id3 = $this->factory->post->create( array( 'post_title' => 'gamma', 'post_tag' => array( $tag1 ) ) );
-               $post_id4 = $this->factory->post->create( array( 'post_title' => 'delta', 'post_tag' => array( $tag2 ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq->transform_query( $tq->queries[0], '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">-                $query = new WP_Query( array(
-                       'fields' => 'ids',
-                       'tax_query' => array(
-                               //'relation' => 'OR',
-                               array(
-                                       'taxonomy' => 'category',
-                                       'field' => 'term_id',
-                                       'terms' => array( $category1, $category2 )
-                               )
-                       )
-               ) );
-               $ids = $query->get_posts();
-               $this->assertEquals( array( $post_id1, $post_id2 ), $ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $query, $tq->queries[0] );
</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_no_taxonomy() {
-               $cat_id = $this->factory->category->create( array( 'name' => 'alpha' ) );
-               $this->factory->post->create( array( 'post_title' => 'alpha', 'post_category' => array( $cat_id ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_resulting_field_sanitized() {
+               $t1 = $this->factory->category->create( array( 'slug' => 'foo', ) );
+               $t2 = $this->factory->category->create( array( 'slug' => 'bar', ) );
+               $p = $this->factory->post->create();
+               wp_set_post_categories( $p, $t1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $response1 = new WP_Query( array(
-                       'tax_query' => array(
-                               array( 'terms' => array( $cat_id ) )
-                       )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq1 = new WP_Tax_Query( array(
+                       array(
+                               '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">-                $this->assertEmpty( $response1->posts );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq1->transform_query( $tq1->queries[0], '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">-                $response2 = new WP_Query( array(
-                       'tax_query' => array(
-                               array(
-                                       'taxonomy' => 'category',
-                                       'terms' => array( $cat_id )
-                               )
-                       )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq2 = new WP_Tax_Query( array(
+                       array(
+                               '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">-                $this->assertNotEmpty( $response2->posts );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq2->transform_query( $tq2->queries[0], 'TERM_ ta%xonomy_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">-                $term = get_category( $cat_id );
-               $response3 = new WP_Query( array(
-                       'tax_query' => array(
-                               array(
-                                       'field' => 'term_taxonomy_id',
-                                       'terms' => array( $term->term_taxonomy_id )
-                               )
-                       )
-               ) );
-               $this->assertNotEmpty( $response3->posts );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $tq1->queries[0], $tq2->queries[0] );
</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_term_taxonomy_id_field_no_taxonomy() {
-               $posts = $this->factory->post->create_many( 5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_field_slug() {
+               $t1 = $this->factory->category->create( array( 'slug' => 'foo', ) );
+               $p = $this->factory->post->create();
+               $tt_ids = wp_set_post_categories( $p, $t1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $cats = $tags = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq = new WP_Tax_Query( array(
+                       array(
+                               'taxonomy' => 'category',
+                               'terms' => array( 'foo' ),
+                               'field' => 'slug',
+                       ),
+               ) );
+               $tq->transform_query( $tq->queries[0], '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">-                // 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' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $tt_ids, $tq->queries[0]['terms'] );
+               $this->assertSame( 'term_taxonomy_id', $tq->queries[0]['field'] );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // 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 );
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_field_name() {
+               $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
+               $p = $this->factory->post->create();
+               $tt_ids = wp_set_post_categories( $p, $t1 );
</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_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' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq = new WP_Tax_Query( array(
+                       array(
+                               'taxonomy' => 'category',
+                               'terms' => array( 'Foo' ),
+                               'field' => 'name',
+                       ),
+               ) );
+               $tq->transform_query( $tq->queries[0], '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">-                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' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( $tt_ids, $tq->queries[0]['terms'] );
+               $this->assertSame( 'term_taxonomy_id', $tq->queries[0]['field'] );
+       }
</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_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' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_field_term_taxonomy_id() {
+               $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
+               $p = $this->factory->post->create();
+               $tt_ids = wp_set_post_categories( $p, $t1 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $results1 = $this->q->query( array(
-                       'fields' => 'ids',
-                       '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,
-                               )
-                       )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $tq = new WP_Tax_Query( array(
+                       array(
+                               'taxonomy' => 'category',
+                               'terms' => $tt_ids,
+                               'field' => 'term_taxonomy_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">+                $tq->transform_query( $tq->queries[0], '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">-                $this->assertEquals( array( $posts[0], $posts[1], $posts[2] ), $results1, 'Relation: OR; Operator: AND' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $t1 ), $tq->queries[0]['terms'] );
+               $this->assertSame( 'term_id', $tq->queries[0]['field'] );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $results2 = $this->q->query( array(
-                       'fields' => 'ids',
-                       '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,
-                               )
-                       )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_field_term_taxonomy_default() {
+               $t1 = $this->factory->category->create( array( 'slug' => 'foo', 'name' => 'Foo', ) );
+               $p = $this->factory->post->create();
+               $tt_ids = wp_set_post_categories( $p, $t1 );
+
+               $tq = new WP_Tax_Query( array(
+                       array(
+                               'taxonomy' => 'category',
+                               'terms' => array( $t1 ),
+                               'field' => 'foo', // Anything defaults to 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">+                $tq->transform_query( $tq->queries[0], '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">-                $this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $tt_ids, $tq->queries[0]['terms'] );
+               $this->assertSame( 'term_taxonomy_id', $tq->queries[0]['field'] );
</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">-        /**
-        * @ticket 28099
-        */
-       function test_empty__in() {
-               $cat_id = $this->factory->category->create();
-               $post_id = $this->factory->post->create();
-               wp_set_post_categories( $post_id, $cat_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_transform_query_nonexistent_terms() {
+               $tq = new WP_Tax_Query( array(
+                       array(
+                               'terms' => array( 'foo' ),
+                               'field' => 'slug',
+                               'operator' => 'AND',
+                       ),
+               ) );
+               $tq->transform_query( $tq->queries[0], '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">-                $q1 = get_posts( array( 'category__in' => array( $cat_id ) ) );
-               $this->assertNotEmpty( $q1 );
-               $q2 = get_posts( array( 'category__in' => array() ) );
-               $this->assertNotEmpty( $q2 );
-
-               $tag = wp_insert_term( 'woo', 'post_tag' );
-               $tag_id = $tag['term_id'];
-               $slug = get_tag( $tag_id )->slug;
-               wp_set_post_tags( $post_id, $slug );
-
-               $q3 = get_posts( array( 'tag__in' => array( $tag_id ) ) );
-               $this->assertNotEmpty( $q3 );
-               $q4 = get_posts( array( 'tag__in' => array() ) );
-               $this->assertNotEmpty( $q4 );
-
-               $q5 = get_posts( array( 'tag_slug__in' => array( $slug ) ) );
-               $this->assertNotEmpty( $q5 );
-               $q6 = get_posts( array( 'tag_slug__in' => array() ) );
-               $this->assertNotEmpty( $q6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( is_wp_error( $tq->queries[0] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>