<!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>[Tests][878] trunk: We are now 100% ported to the new test runner.</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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd><a href="http://unit-tests.trac.wordpress.org/changeset/878">878</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-07-03 19:14:58 +0000 (Tue, 03 Jul 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>We are now 100% ported to the new test runner. Port over test_query_results.php.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkphpunitxml">trunk/phpunit.xml</a></li>
<li><a href="#trunkteststest_query_resultsphp">trunk/tests/test_query_results.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkphpunitxml"></a>
<div class="modfile"><h4>Modified: trunk/phpunit.xml (877 => 878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/phpunit.xml        2012-07-03 18:23:14 UTC (rev 877)
+++ trunk/phpunit.xml        2012-07-03 19:14:58 UTC (rev 878)
</span><span class="lines">@@ -8,7 +8,6 @@
</span><span class="cx">         &lt;testsuite&gt;
</span><span class="cx">             &lt;directory suffix=&quot;.php&quot;&gt;tests&lt;/directory&gt;
</span><span class="cx">             &lt;file phpVersion=&quot;5.3.0&quot;&gt;tests/test_actions_closures.php&lt;/file&gt;
</span><del>-            &lt;exclude&gt;tests/test_query_results.php&lt;/exclude&gt;
</del><span class="cx">         &lt;/testsuite&gt;
</span><span class="cx">     &lt;/testsuites&gt;
</span><span class="cx"> &lt;/phpunit&gt;
</span></span></pre></div>
<a id="trunkteststest_query_resultsphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/test_query_results.php (877 => 878)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/test_query_results.php        2012-07-03 18:23:14 UTC (rev 877)
+++ trunk/tests/test_query_results.php        2012-07-03 19:14:58 UTC (rev 878)
</span><span class="lines">@@ -3,29 +3,50 @@
</span><span class="cx"> // Test various query vars and make sure the WP_Query class selects the correct posts.
</span><span class="cx"> // We're testing against a known data set, so we can check that specific posts are included in the output.
</span><span class="cx"> 
</span><del>-class TestWPQueryPosts extends _WPDataset1 {
</del><ins>+class TestWPQueryPosts extends WP_UnitTestCase {
+        protected $q;
+
</ins><span class="cx">         function setUp() {
</span><span class="cx">                 parent::setUp();
</span><del>-                $this-&gt;q = new WP_Query();
-        }
</del><span class="cx"> 
</span><del>-        function tearDown() {
-                parent::tearDown();
-                unset($this-&gt;q);
-        }
</del><ins>+                $cat_a = $this-&gt;factory-&gt;term-&gt;create( array( 'taxonomy' =&gt; 'category', 'name' =&gt; 'cat-a' ) );
+                $cat_b = $this-&gt;factory-&gt;term-&gt;create( array( 'taxonomy' =&gt; 'category', 'name' =&gt; 'cat-b' ) );
+                $cat_c = $this-&gt;factory-&gt;term-&gt;create( array( 'taxonomy' =&gt; 'category', 'name' =&gt; 'cat-c' ) );
</ins><span class="cx"> 
</span><del>-        function post_slugs($posts) {
-                $out = array();
-                foreach ($posts as $post)
-                        $out[] = $post-&gt;post_name;
-                return $out;
</del><ins>+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cats-a-b-c', 'post_date' =&gt; '2008-12-01 00:00:00', 'post_category' =&gt; array( $cat_a, $cat_b, $cat_c ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cats-a-and-b', 'post_date' =&gt; '2009-01-01 00:00:00', 'post_category' =&gt; array( $cat_a, $cat_b ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cats-b-and-c', 'post_date' =&gt; '2009-02-01 00:00:00', 'post_category' =&gt; array( $cat_b, $cat_c ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cats-a-and-c', 'post_date' =&gt; '2009-03-01 00:00:00', 'post_category' =&gt; array( $cat_a, $cat_c ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cat-a', 'post_date' =&gt; '2009-04-01 00:00:00', 'post_category' =&gt; array( $cat_a ) ) );                
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cat-b', 'post_date' =&gt; '2009-05-01 00:00:00', 'post_category' =&gt; array( $cat_b ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'cat-c', 'post_date' =&gt; '2009-06-01 00:00:00', 'post_category' =&gt; array( $cat_c ) ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'lorem-ipsum', 'post_date' =&gt; '2009-07-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'comment-test', 'post_date' =&gt; '2009-08-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'one-trackback', 'post_date' =&gt; '2009-09-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'many-trackbacks', 'post_date' =&gt; '2009-10-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'no-comments', 'post_date' =&gt; '2009-10-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'one-comment', 'post_date' =&gt; '2009-11-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'contributor-post-approved', 'post_date' =&gt; '2009-12-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'embedded-video', 'post_date' =&gt; '2010-01-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'simple-markup-test', 'post_date' =&gt; '2010-02-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'raw-html-code', 'post_date' =&gt; '2010-03-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tags-a-b-c', 'tags_input' =&gt; array( 'tag-a', 'tag-b', 'tag-c' ), 'post_date' =&gt; '2010-04-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tag-a', 'tags_input' =&gt; array( 'tag-a' ), 'post_date' =&gt; '2010-05-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tag-b', 'tags_input' =&gt; array( 'tag-b' ), 'post_date' =&gt; '2010-06-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tag-c', 'tags_input' =&gt; array( 'tag-c' ), 'post_date' =&gt; '2010-07-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tags-a-and-b', 'tags_input' =&gt; array( 'tag-a', 'tag-b' ), 'post_date' =&gt; '2010-08-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tags-b-and-c', 'tags_input' =&gt; array( 'tag-b', 'tag-c' ), 'post_date' =&gt; '2010-09-01 00:00:00' ) );
+                $this-&gt;factory-&gt;post-&gt;create( array( 'post_title' =&gt; 'tags-a-and-c', 'tags_input' =&gt; array( 'tag-a', 'tag-c' ), 'post_date' =&gt; '2010-10-01 00:00:00' ) );
+
+                unset( $this-&gt;q );
+                $this-&gt;q = new WP_Query();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_default() {
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query('');
</span><span class="cx"> 
</span><span class="cx">                 // the output should be the most recent 10 posts as listed here
</span><del>-                $expected = array (
</del><ins>+                $expected = array(
</ins><span class="cx">                         0 =&gt; 'tags-a-and-c',
</span><span class="cx">                         1 =&gt; 'tags-b-and-c',
</span><span class="cx">                         2 =&gt; 'tags-a-and-b',
</span><span class="lines">@@ -38,14 +59,14 @@
</span><span class="cx">                         9 =&gt; 'embedded-video',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_tag_a() {
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query('tag=tag-a');
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-b', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tag-a', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -56,7 +77,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query('tag=tag-b');
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-b-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-b', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tag-b', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -68,7 +89,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query(&quot;tag_id={$tag[term_id]}&quot;);
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-b', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tag-a', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -79,7 +100,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query(&quot;tag_slug__in[]=tag-b&amp;tag_slug__in[]=tag-c&quot;);
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with either Tag B or Tag C
</span><del>-                $this-&gt;assertEquals( 6, count($posts) );
</del><ins>+                $this-&gt;assertCount( 6, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-b-and-c', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-b', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -95,7 +116,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query(&quot;tag__in[]={$tag_a[term_id]}&amp;tag__in[]={$tag_b[term_id]}&quot;);
</span><span class="cx"> 
</span><span class="cx">                 // there are 6 posts with either Tag A or Tag B
</span><del>-                $this-&gt;assertEquals( 6, count($posts) );
</del><ins>+                $this-&gt;assertCount( 6, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-b-and-c', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-b', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -123,7 +144,7 @@
</span><span class="cx">                         9 =&gt; 'many-trackbacks',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_tag__in_but__not_in() {
</span><span class="lines">@@ -132,7 +153,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query(&quot;tag__in[]={$tag_a[term_id]}&amp;tag__not_in[]={$tag_b[term_id]}&quot;);
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Tag A, only 2 when we exclude Tag B
</span><del>-                $this-&gt;assertEquals( 2, count($posts) );
</del><ins>+                $this-&gt;assertCount( 2, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'tags-a-and-c', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'tag-a', $posts[1]-&gt;post_name );
</span><span class="cx">         }
</span><span class="lines">@@ -143,7 +164,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query('category_name=cat-a');
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Cat A, we'll check for them by name
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'cat-a', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'cats-a-and-c', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'cats-a-and-b', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -155,7 +176,7 @@
</span><span class="cx">                 $posts = $this-&gt;q-&gt;query(&quot;cat=$cat&quot;);
</span><span class="cx"> 
</span><span class="cx">                 // there are 4 posts with Cat B
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertEquals( 'cat-b', $posts[0]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'cats-b-and-c', $posts[1]-&gt;post_name );
</span><span class="cx">                 $this-&gt;assertEquals( 'cats-a-and-b', $posts[2]-&gt;post_name );
</span><span class="lines">@@ -173,8 +194,8 @@
</span><span class="cx">                         4 =&gt; 'tag-b',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( 5, count($posts) );
-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertCount( 5, $posts );
+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_offset() {
</span><span class="lines">@@ -193,8 +214,8 @@
</span><span class="cx">                         9 =&gt; 'one-comment',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( 10, count($posts) );
-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertCount( 10, $posts );
+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_paged() {
</span><span class="lines">@@ -213,9 +234,9 @@
</span><span class="cx">                         9 =&gt; 'cat-a',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( 10, count($posts) );
</del><ins>+                $this-&gt;assertCount( 10, $posts );
</ins><span class="cx">                 $this-&gt;assertTrue( $this-&gt;q-&gt;is_paged() );
</span><del>-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_paged_and_posts_per_page() {
</span><span class="lines">@@ -228,9 +249,9 @@
</span><span class="cx">                         3 =&gt; 'comment-test',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( 4, count($posts) );
</del><ins>+                $this-&gt;assertCount( 4, $posts );
</ins><span class="cx">                 $this-&gt;assertTrue( $this-&gt;q-&gt;is_paged() );
</span><del>-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function test_query_offset_and_paged() {
</span><span class="lines">@@ -251,9 +272,9 @@
</span><span class="cx">                         9 =&gt; 'cats-a-and-b',
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals( 10, count($posts) );
</del><ins>+                $this-&gt;assertCount( 10, $posts );
</ins><span class="cx">                 $this-&gt;assertTrue( $this-&gt;q-&gt;is_paged() );
</span><del>-                $this-&gt;assertEquals( $expected, $this-&gt;post_slugs($posts) );
</del><ins>+                $this-&gt;assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>