<!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>[55583] trunk/tests/phpunit/tests/post/getPages.php: Tests: Improve `get_pages()` tests organization.</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 { white-space: pre-line; 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/55583">55583</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/55583","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-03-23 11:35:21 +0000 (Thu, 23 Mar 2023)</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'>Tests: Improve `get_pages()` tests organization.
Includes:
* Renaming some tests for clarity.
* Moving some tests to a more appropriate place.
* Moving the `@covers` tag to the top of the class.
* Using consistent formatting for assertion messages.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/27767">[27767]</a>, <a href="https://core.trac.wordpress.org/changeset/41849">[41849]</a>, <a href="https://core.trac.wordpress.org/changeset/44587">[44587]</a>, <a href="https://core.trac.wordpress.org/changeset/55569">[55569]</a>.
See <a href="https://core.trac.wordpress.org/ticket/57841">#57841</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestspostgetPagesphp">trunk/tests/phpunit/tests/post/getPages.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestspostgetPagesphp"></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/getPages.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/getPages.php 2023-03-22 12:48:30 UTC (rev 55582)
+++ trunk/tests/phpunit/tests/post/getPages.php 2023-03-23 11:35:21 UTC (rev 55583)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,8 +2,9 @@
</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"> * @group post
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @covers ::get_pages
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> class Tests_Post_GetPages extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 23167
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,9 +101,31 @@
</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">+ * @ticket 43514
+ */
+ public function test_get_pages_cache_empty() {
+ global $wpdb;
+
+ wp_cache_delete( 'last_changed', 'posts' );
+ $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
+
+ $num_queries = $wpdb->num_queries;
+
+ $pages = get_pages(); // Database gets queried.
+
+ $this->assertSame( $num_queries + 1, $wpdb->num_queries );
+
+ $num_queries = $wpdb->num_queries;
+
+ $pages = get_pages(); // Database should not get queried.
+
+ $this->assertSame( $num_queries, $wpdb->num_queries );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40669
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_cache_should_be_invalidated_by_add_post_meta() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_cache_should_be_invalidated_by_add_post_meta() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many(
</span><span class="cx" style="display: block; padding: 0 10px"> 2,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -138,7 +161,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40669
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_cache_should_be_invalidated_by_update_post_meta() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_cache_should_be_invalidated_by_update_post_meta() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many(
</span><span class="cx" style="display: block; padding: 0 10px"> 2,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -173,63 +196,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 12821
- * @covers ::get_pages
- */
- public function test_include_ignore_meta_key() {
- $posts = self::factory()->post->create_many(
- 2,
- array(
- 'post_type' => 'page',
- )
- );
-
- $pages = get_pages(
- array(
- 'include' => $posts,
- 'meta_key' => 'foo',
- 'meta_value' => 'bar',
- )
- );
-
- $page_ids = wp_list_pluck( $pages, 'ID' );
- $this->assertSameSets( $posts, $page_ids );
- }
-
- /**
- * @ticket 12821
- * @covers ::get_pages
- */
- public function test_include_ignore_exclude() {
- $includes = self::factory()->post->create_many(
- 2,
- array(
- 'post_type' => 'page',
- )
- );
-
- $excludes = self::factory()->post->create_many(
- 2,
- array(
- 'post_type' => 'page',
- )
- );
-
- $pages = get_pages(
- array(
- 'include' => $includes,
- 'exclude' => $excludes,
- )
- );
-
- $page_ids = wp_list_pluck( $pages, 'ID' );
- $this->assertSameSets( $includes, $page_ids );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40669
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_cache_should_be_invalidated_by_delete_post_meta() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many(
</span><span class="cx" style="display: block; padding: 0 10px"> 2,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -266,7 +235,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 40669
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_cache_should_be_invalidated_by_delete_post_meta_by_key() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_cache_should_be_invalidated_by_delete_post_meta_by_key() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many(
</span><span class="cx" style="display: block; padding: 0 10px"> 2,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,6 +330,105 @@
</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">+ * @ticket 12821
+ */
+ public function test_get_pages_include_ignores_meta_key() {
+ $posts = self::factory()->post->create_many(
+ 2,
+ array(
+ 'post_type' => 'page',
+ )
+ );
+
+ $pages = get_pages(
+ array(
+ 'include' => $posts,
+ 'meta_key' => 'foo',
+ 'meta_value' => 'bar',
+ )
+ );
+
+ $page_ids = wp_list_pluck( $pages, 'ID' );
+ $this->assertSameSets( $posts, $page_ids );
+ }
+
+ /**
+ * @ticket 12821
+ */
+ public function test_get_pages_include_ignores_exclude() {
+ $includes = self::factory()->post->create_many(
+ 2,
+ array(
+ 'post_type' => 'page',
+ )
+ );
+
+ $excludes = self::factory()->post->create_many(
+ 2,
+ array(
+ 'post_type' => 'page',
+ )
+ );
+
+ $pages = get_pages(
+ array(
+ 'include' => $includes,
+ 'exclude' => $excludes,
+ )
+ );
+
+ $page_ids = wp_list_pluck( $pages, 'ID' );
+ $this->assertSameSets( $includes, $page_ids );
+ }
+
+ public function test_get_pages_exclude_tree() {
+ $post_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
+ $post_id2 = self::factory()->post->create(
+ array(
+ 'post_type' => 'page',
+ 'post_parent' => $post_id1,
+ )
+ );
+ $post_id3 = self::factory()->post->create( array( 'post_type' => 'page' ) );
+ $post_id4 = self::factory()->post->create(
+ array(
+ 'post_type' => 'page',
+ 'post_parent' => $post_id3,
+ )
+ );
+
+ $all = get_pages();
+
+ $this->assertCount( 4, $all );
+
+ $exclude1 = get_pages( "exclude_tree=$post_id1" );
+ $this->assertCount( 2, $exclude1 );
+
+ $exclude2 = get_pages( array( 'exclude_tree' => $post_id1 ) );
+ $this->assertCount( 2, $exclude2 );
+
+ $exclude3 = get_pages( array( 'exclude_tree' => array( $post_id1 ) ) );
+ $this->assertCount( 2, $exclude3 );
+
+ $exclude4 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id2 ) ) );
+ $this->assertCount( 2, $exclude4 );
+
+ $exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
+ $this->assertCount( 0, $exclude5 );
+
+ $post_id5 = self::factory()->post->create( array( 'post_type' => 'page' ) );
+ $post_id6 = self::factory()->post->create(
+ array(
+ 'post_type' => 'page',
+ 'post_parent' => $post_id5,
+ )
+ );
+
+ $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
+ $this->assertCount( 2, $exclude6 );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 9470
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_parent() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,7 +500,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 22208
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_chidren_fields_ids() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_children_fields_ids() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px"> $child_ids = self::factory()->post->create_many( 5, array( 'post_parent' => $post_id ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,78 +773,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> _unregister_post_type( $type );
</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">- public function test_exclude_tree() {
- $post_id1 = self::factory()->post->create( array( 'post_type' => 'page' ) );
- $post_id2 = self::factory()->post->create(
- array(
- 'post_type' => 'page',
- 'post_parent' => $post_id1,
- )
- );
- $post_id3 = self::factory()->post->create( array( 'post_type' => 'page' ) );
- $post_id4 = self::factory()->post->create(
- array(
- 'post_type' => 'page',
- 'post_parent' => $post_id3,
- )
- );
-
- $all = get_pages();
-
- $this->assertCount( 4, $all );
-
- $exclude1 = get_pages( "exclude_tree=$post_id1" );
- $this->assertCount( 2, $exclude1 );
-
- $exclude2 = get_pages( array( 'exclude_tree' => $post_id1 ) );
- $this->assertCount( 2, $exclude2 );
-
- $exclude3 = get_pages( array( 'exclude_tree' => array( $post_id1 ) ) );
- $this->assertCount( 2, $exclude3 );
-
- $exclude4 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id2 ) ) );
- $this->assertCount( 2, $exclude4 );
-
- $exclude5 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
- $this->assertCount( 0, $exclude5 );
-
- $post_id5 = self::factory()->post->create( array( 'post_type' => 'page' ) );
- $post_id6 = self::factory()->post->create(
- array(
- 'post_type' => 'page',
- 'post_parent' => $post_id5,
- )
- );
-
- $exclude6 = get_pages( array( 'exclude_tree' => array( $post_id1, $post_id3 ) ) );
- $this->assertCount( 2, $exclude6 );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @ticket 43514
- */
- public function test_get_pages_cache_empty() {
- global $wpdb;
-
- wp_cache_delete( 'last_changed', 'posts' );
- $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) );
-
- $num_queries = $wpdb->num_queries;
-
- $pages = get_pages(); // Database gets queried.
-
- $this->assertSame( $num_queries + 1, $wpdb->num_queries );
-
- $num_queries = $wpdb->num_queries;
-
- $pages = get_pages(); // Database should not get queried.
-
- $this->assertSame( $num_queries, $wpdb->num_queries );
- }
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_post_type() {
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'wptests_pt', array( 'hierarchical' => true ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -789,39 +787,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( $posts, wp_list_pluck( $pages, 'ID' ) );
</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">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_pages_author() {
- $author_1 = self::factory()->user->create(
- array(
- 'user_login' => 'author1',
- 'role' => 'author',
- )
- );
- $posts = self::factory()->post->create_many(
- 2,
- array(
- 'post_type' => 'page',
- 'post_author' => $author_1,
- )
- );
- $pages = get_pages(
- array(
- 'authors' => $author_1,
- )
- );
-
- $this->assertSameSets( $posts, wp_list_pluck( $pages, 'ID' ) );
- }
-
-
- /**
- * @ticket 12821
- * @covers ::get_pages
- */
</del><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_post_status() {
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_status(
</span><span class="cx" style="display: block; padding: 0 10px"> 'foo',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -848,7 +816,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_pages_offset() {
</span><span class="cx" style="display: block; padding: 0 10px"> $posts = self::factory()->post->create_many( 4, array( 'post_type' => 'page' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -862,12 +829,36 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( $posts[2], $posts[3] ), wp_list_pluck( $pages, 'ID' ) );
</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">+ /**
+ * @ticket 12821
+ */
+ public function test_get_pages_author() {
+ $author_1 = self::factory()->user->create(
+ array(
+ 'user_login' => 'author1',
+ 'role' => 'author',
+ )
+ );
+ $posts = self::factory()->post->create_many(
+ 2,
+ array(
+ 'post_type' => 'page',
+ 'post_author' => $author_1,
+ )
+ );
+ $pages = get_pages(
+ array(
+ 'authors' => $author_1,
+ )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( $posts, wp_list_pluck( $pages, 'ID' ) );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_pages_authors() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_multiple_authors() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $author_1 = self::factory()->user->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'author1',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -908,9 +899,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_get_pages_authors_names() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_multiple_authors_by_user_login() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $author_1 = self::factory()->user->create(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'author1',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -951,40 +941,74 @@
</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"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_orderby() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_orderby() {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> // 'rand' is a valid value.
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages( array( 'sort_column' => 'rand' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringContainsString( 'ORDER BY RAND()', $wpdb->last_query, 'Check order is random' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString(
+ 'ORDER BY RAND()',
+ $wpdb->last_query,
+ 'Check that ORDER is random.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // This isn't allowed.
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages( array( 'sort_order' => 'rand' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringContainsString( 'ORDER BY', $wpdb->last_query, 'Check orderby is present' );
- $this->assertStringNotContainsString( 'RAND()', $wpdb->last_query, 'Check order is random is not present' );
- $this->assertStringContainsString( 'DESC', $wpdb->last_query, 'Check DESC is random is not present' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString(
+ 'ORDER BY',
+ $wpdb->last_query,
+ 'Check that ORDER BY is present.'
+ );
+ $this->assertStringNotContainsString(
+ 'RAND()',
+ $wpdb->last_query,
+ 'Check that ORDER is not random.'
+ );
+ $this->assertStringContainsString(
+ 'DESC',
+ $wpdb->last_query,
+ 'Check that DESC is not present.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // 'none' is a valid value.
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages( array( 'sort_column' => 'none' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringNotContainsString( 'ORDER BY', $wpdb->last_query, 'Check orderby is not present' );
- $this->assertStringNotContainsString( 'DESC', $wpdb->last_query, 'Check DESC is not present' );
- $this->assertStringNotContainsString( 'ASC', $wpdb->last_query, 'Check ASC is not present' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringNotContainsString(
+ 'ORDER BY',
+ $wpdb->last_query,
+ 'Check that ORDER BY is not present.'
+ );
+ $this->assertStringNotContainsString(
+ 'DESC',
+ $wpdb->last_query,
+ 'Check that DESC is not present.'
+ );
+ $this->assertStringNotContainsString(
+ 'ASC',
+ $wpdb->last_query,
+ 'Check that ASC is not present.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // False is a valid value.
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages( array( 'sort_column' => false ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringContainsString( 'ORDER BY', $wpdb->last_query, 'Check orderby is present if sort_column equal false is passed.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString(
+ 'ORDER BY',
+ $wpdb->last_query,
+ 'Check that ORDER BY is present if sort_column is false.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Empty array() is a valid value.
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages( array( 'sort_column' => array() ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringContainsString( 'ORDER BY', $wpdb->last_query, 'Check orderby is present if sort_column equals an empty array is passed.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString(
+ 'ORDER BY',
+ $wpdb->last_query,
+ 'Check that ORDER BY is present if sort_column is an empty array.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 12821
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @covers ::get_pages
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_order() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_get_pages_order() {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -995,7 +1019,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString(
</span><span class="cx" style="display: block; padding: 0 10px"> "ORDER BY $wpdb->posts.post_type ASC",
</span><span class="cx" style="display: block; padding: 0 10px"> $wpdb->last_query,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Check order is post type'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Check that ORDER is post type.'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1007,7 +1031,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString(
</span><span class="cx" style="display: block; padding: 0 10px"> "ORDER BY $wpdb->posts.post_title DESC",
</span><span class="cx" style="display: block; padding: 0 10px"> $wpdb->last_query,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Check order is default'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Check that ORDER is default.'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> get_pages(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1019,7 +1043,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString(
</span><span class="cx" style="display: block; padding: 0 10px"> "ORDER BY $wpdb->posts.post_date ASC",
</span><span class="cx" style="display: block; padding: 0 10px"> $wpdb->last_query,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'Check order is post date'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Check that ORDER is post date.'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>