<!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"> <testsuite>
</span><span class="cx"> <directory suffix=".php">tests</directory>
</span><span class="cx"> <file phpVersion="5.3.0">tests/test_actions_closures.php</file>
</span><del>- <exclude>tests/test_query_results.php</exclude>
</del><span class="cx"> </testsuite>
</span><span class="cx"> </testsuites>
</span><span class="cx"> </phpunit>
</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->q = new WP_Query();
-        }
</del><span class="cx">
</span><del>-        function tearDown() {
-                parent::tearDown();
-                unset($this->q);
-        }
</del><ins>+                $cat_a = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-a' ) );
+                $cat_b = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-b' ) );
+                $cat_c = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'cat-c' ) );
</ins><span class="cx">
</span><del>-        function post_slugs($posts) {
-                $out = array();
-                foreach ($posts as $post)
-                        $out[] = $post->post_name;
-                return $out;
</del><ins>+                $this->factory->post->create( array( 'post_title' => 'cats-a-b-c', 'post_date' => '2008-12-01 00:00:00', 'post_category' => array( $cat_a, $cat_b, $cat_c ) ) );
+                $this->factory->post->create( array( 'post_title' => 'cats-a-and-b', 'post_date' => '2009-01-01 00:00:00', 'post_category' => array( $cat_a, $cat_b ) ) );
+                $this->factory->post->create( array( 'post_title' => 'cats-b-and-c', 'post_date' => '2009-02-01 00:00:00', 'post_category' => array( $cat_b, $cat_c ) ) );
+                $this->factory->post->create( array( 'post_title' => 'cats-a-and-c', 'post_date' => '2009-03-01 00:00:00', 'post_category' => array( $cat_a, $cat_c ) ) );
+                $this->factory->post->create( array( 'post_title' => 'cat-a', 'post_date' => '2009-04-01 00:00:00', 'post_category' => array( $cat_a ) ) );                
+                $this->factory->post->create( array( 'post_title' => 'cat-b', 'post_date' => '2009-05-01 00:00:00', 'post_category' => array( $cat_b ) ) );
+                $this->factory->post->create( array( 'post_title' => 'cat-c', 'post_date' => '2009-06-01 00:00:00', 'post_category' => array( $cat_c ) ) );
+                $this->factory->post->create( array( 'post_title' => 'lorem-ipsum', 'post_date' => '2009-07-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'comment-test', 'post_date' => '2009-08-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'one-trackback', 'post_date' => '2009-09-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'many-trackbacks', 'post_date' => '2009-10-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'no-comments', 'post_date' => '2009-10-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'one-comment', 'post_date' => '2009-11-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'contributor-post-approved', 'post_date' => '2009-12-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'embedded-video', 'post_date' => '2010-01-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'simple-markup-test', 'post_date' => '2010-02-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'raw-html-code', 'post_date' => '2010-03-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tags-a-b-c', 'tags_input' => array( 'tag-a', 'tag-b', 'tag-c' ), 'post_date' => '2010-04-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tag-a', 'tags_input' => array( 'tag-a' ), 'post_date' => '2010-05-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tag-b', 'tags_input' => array( 'tag-b' ), 'post_date' => '2010-06-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tag-c', 'tags_input' => array( 'tag-c' ), 'post_date' => '2010-07-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tags-a-and-b', 'tags_input' => array( 'tag-a', 'tag-b' ), 'post_date' => '2010-08-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tags-b-and-c', 'tags_input' => array( 'tag-b', 'tag-c' ), 'post_date' => '2010-09-01 00:00:00' ) );
+                $this->factory->post->create( array( 'post_title' => 'tags-a-and-c', 'tags_input' => array( 'tag-a', 'tag-c' ), 'post_date' => '2010-10-01 00:00:00' ) );
+
+                unset( $this->q );
+                $this->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->q->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 => 'tags-a-and-c',
</span><span class="cx">                         1 => 'tags-b-and-c',
</span><span class="cx">                         2 => 'tags-a-and-b',
</span><span class="lines">@@ -38,14 +59,14 @@
</span><span class="cx">                         9 => 'embedded-video',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->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->q->query('tag=tag-a');
</span><span class="cx">
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tag-a', $posts[2]->post_name );
</span><span class="lines">@@ -56,7 +77,7 @@
</span><span class="cx">                 $posts = $this->q->query('tag=tag-b');
</span><span class="cx">
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-b-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tag-b', $posts[2]->post_name );
</span><span class="lines">@@ -68,7 +89,7 @@
</span><span class="cx">                 $posts = $this->q->query("tag_id={$tag[term_id]}");
</span><span class="cx">
</span><span class="cx">                 // there are 4 posts with Tag A
</span><del>-                $this->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tag-a', $posts[2]->post_name );
</span><span class="lines">@@ -79,7 +100,7 @@
</span><span class="cx">                 $posts = $this->q->query("tag_slug__in[]=tag-b&tag_slug__in[]=tag-c");
</span><span class="cx">
</span><span class="cx">                 // there are 4 posts with either Tag B or Tag C
</span><del>-                $this->assertEquals( 6, count($posts) );
</del><ins>+                $this->assertCount( 6, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-b-and-c', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-a-and-b', $posts[2]->post_name );
</span><span class="lines">@@ -95,7 +116,7 @@
</span><span class="cx">                 $posts = $this->q->query("tag__in[]={$tag_a[term_id]}&tag__in[]={$tag_b[term_id]}");
</span><span class="cx">
</span><span class="cx">                 // there are 6 posts with either Tag A or Tag B
</span><del>-                $this->assertEquals( 6, count($posts) );
</del><ins>+                $this->assertCount( 6, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-b-and-c', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tags-a-and-b', $posts[2]->post_name );
</span><span class="lines">@@ -123,7 +144,7 @@
</span><span class="cx">                         9 => 'many-trackbacks',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->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->q->query("tag__in[]={$tag_a[term_id]}&tag__not_in[]={$tag_b[term_id]}");
</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->assertEquals( 2, count($posts) );
</del><ins>+                $this->assertCount( 2, $posts );
</ins><span class="cx">                 $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'tag-a', $posts[1]->post_name );
</span><span class="cx">         }
</span><span class="lines">@@ -143,7 +164,7 @@
</span><span class="cx">                 $posts = $this->q->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->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertEquals( 'cat-a', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'cats-a-and-c', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'cats-a-and-b', $posts[2]->post_name );
</span><span class="lines">@@ -155,7 +176,7 @@
</span><span class="cx">                 $posts = $this->q->query("cat=$cat");
</span><span class="cx">
</span><span class="cx">                 // there are 4 posts with Cat B
</span><del>-                $this->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertEquals( 'cat-b', $posts[0]->post_name );
</span><span class="cx">                 $this->assertEquals( 'cats-b-and-c', $posts[1]->post_name );
</span><span class="cx">                 $this->assertEquals( 'cats-a-and-b', $posts[2]->post_name );
</span><span class="lines">@@ -173,8 +194,8 @@
</span><span class="cx">                         4 => 'tag-b',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( 5, count($posts) );
-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->assertCount( 5, $posts );
+                $this->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 => 'one-comment',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( 10, count($posts) );
-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->assertCount( 10, $posts );
+                $this->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 => 'cat-a',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( 10, count($posts) );
</del><ins>+                $this->assertCount( 10, $posts );
</ins><span class="cx">                 $this->assertTrue( $this->q->is_paged() );
</span><del>-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->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 => 'comment-test',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( 4, count($posts) );
</del><ins>+                $this->assertCount( 4, $posts );
</ins><span class="cx">                 $this->assertTrue( $this->q->is_paged() );
</span><del>-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->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 => 'cats-a-and-b',
</span><span class="cx">                 );
</span><span class="cx">
</span><del>-                $this->assertEquals( 10, count($posts) );
</del><ins>+                $this->assertCount( 10, $posts );
</ins><span class="cx">                 $this->assertTrue( $this->q->is_paged() );
</span><del>-                $this->assertEquals( $expected, $this->post_slugs($posts) );
</del><ins>+                $this->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>