<!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>[46829] trunk/tests/phpunit/tests/comment-submission.php: Tests: Speed up comment submission unit tests by creating less fixtures and reusing them where possible.</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/46829">46829</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/46829","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>2019-12-08 18:00:23 +0000 (Sun, 08 Dec 2019)</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: Speed up comment submission unit tests by creating less fixtures and reusing them where possible.
See <a href="https://core.trac.wordpress.org/ticket/30017">#30017</a>, <a href="https://core.trac.wordpress.org/ticket/48145">#48145</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestscommentsubmissionphp">trunk/tests/phpunit/tests/comment-submission.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestscommentsubmissionphp"></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/comment-submission.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment-submission.php 2019-12-07 14:01:44 UTC (rev 46828)
+++ trunk/tests/phpunit/tests/comment-submission.php 2019-12-08 18:00:23 UTC (rev 46829)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,8 +5,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Comment_Submission extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post;
+ protected static $author_id;
+ protected static $editor_id;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $preprocess_comment_data = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$post = $factory->post->create_and_get();
+
+ self::$author_id = $factory->user->create(
+ array(
+ 'role' => 'author',
+ )
+ );
+
+ self::$editor_id = $factory->user->create(
+ array(
+ 'role' => 'editor',
+ )
+ );
+ }
+
+ public static function wpTearDownAfterClass() {
+ wp_delete_post( self::$post->ID, true );
+
+ self::delete_user( self::$author_id );
+ self::delete_user( self::$editor_id );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . WPINC . '/class-phpass.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,11 +61,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_status' => 'closed',
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,13 +84,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
- wp_trash_post( $post->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_trash_post( self::$post->ID );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = wp_handle_comment_submission( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_untrash_post( self::$post->ID );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 1, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $comment );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $error, $comment->get_error_code() );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,11 +104,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'draft',
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -97,22 +128,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_to_draft_post_returns_error_message_for_user_with_correct_caps() {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_on_draft';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_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_current_user( $user->ID );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'draft',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $user->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -156,11 +182,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 0, did_action( $error ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_password' => 'password',
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -179,11 +206,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] = $hasher->HashPassword( $password );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_password' => $password,
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -209,9 +237,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = wp_handle_comment_submission( $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -229,9 +256,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_valid_comment_anonymously_succeeds() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -257,9 +283,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_handles_slashes_correctly_handles_slashes() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment with 1 slash: \\',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author with 1 slash: \\',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -279,11 +304,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_id_not_found';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -299,25 +325,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_id_not_found';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $author = self::factory()->user->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = self::factory()->user->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</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">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $author->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -333,26 +355,22 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_id_not_found';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $author = self::factory()->user->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = self::factory()->user->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</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">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $author->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_status' => 'closed',
</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">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -366,16 +384,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_to_own_private_post_succeeds() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_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_current_user( $user->ID );
-
- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $user->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -390,25 +407,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_to_accessible_private_post_succeeds() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $author = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'editor',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_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_current_user( $user->ID );
-
- $post = self::factory()->post->create_and_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post = self::factory()->post->create_and_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $author->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post->ID,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,9 +430,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_anonymous_user_cannot_comment_unfiltered_html() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment <script>alert(document.cookie);</script>',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -440,18 +446,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_unprivileged_user_cannot_comment_unfiltered_html() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
- wp_set_current_user( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( current_user_can( 'unfiltered_html' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment <script>alert(document.cookie);</script>',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = wp_handle_comment_submission( $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -464,23 +464,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_unprivileged_user_cannot_comment_unfiltered_html_even_with_valid_nonce() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
- wp_set_current_user( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( current_user_can( 'unfiltered_html' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
- $action = 'unfiltered-html-comment_' . $post->ID;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $action = 'unfiltered-html-comment_' . self::$post->ID;
</ins><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( $action );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( wp_verify_nonce( $nonce, $action ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment <script>alert(document.cookie);</script>',
</span><span class="cx" style="display: block; padding: 0 10px"> '_wp_unfiltered_html_comment' => $nonce,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -496,30 +490,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( defined( 'DISALLOW_UNFILTERED_HTML' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'editor',
- )
- );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // In multisite, only Super Admins can post unfiltered HTML
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( user_can( $user->ID, 'unfiltered_html' ) );
- grant_super_admin( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( user_can( self::$editor_id, 'unfiltered_html' ) );
+ grant_super_admin( self::$editor_id );
</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">- wp_set_current_user( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( current_user_can( 'unfiltered_html' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
- $action = 'unfiltered-html-comment_' . $post->ID;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $action = 'unfiltered-html-comment_' . self::$post->ID;
</ins><span class="cx" style="display: block; padding: 0 10px"> $nonce = wp_create_nonce( $action );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( wp_verify_nonce( $nonce, $action ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment <script>alert(document.cookie);</script>',
</span><span class="cx" style="display: block; padding: 0 10px"> '_wp_unfiltered_html_comment' => $nonce,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -533,25 +520,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_privileged_user_cannot_comment_unfiltered_html_without_valid_nonce() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'editor',
- )
- );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // In multisite, only Super Admins can post unfiltered HTML
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse( user_can( $user->ID, 'unfiltered_html' ) );
- grant_super_admin( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( user_can( self::$editor_id, 'unfiltered_html' ) );
+ grant_super_admin( self::$editor_id );
</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">- wp_set_current_user( $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( self::$editor_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( current_user_can( 'unfiltered_html' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment <script>alert(document.cookie);</script>',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = wp_handle_comment_submission( $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -569,9 +549,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_comment_registration = get_option( 'comment_registration' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'comment_registration', '1' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = wp_handle_comment_submission( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -589,9 +568,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_require_name_email = get_option( 'require_name_email' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', '1' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -611,9 +589,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_require_name_email = get_option( 'require_name_email' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', '1' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -633,9 +610,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_require_name_email = get_option( 'require_name_email' );
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'require_name_email', '1' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'not_an_email',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -653,9 +629,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'require_valid_comment';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -673,10 +648,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_with_content_too_long_returns_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_content_column_length';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
-
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => rand_long_str( 65536 ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -693,10 +666,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_with_author_too_long_returns_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_author_column_length';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
-
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => rand_long_str( 255 ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -713,10 +684,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_with_email_too_long_returns_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_author_email_column_length';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
-
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => rand_long_str( 90 ) . '@example.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -733,9 +702,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_comment_with_url_too_long_returns_error() {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = 'comment_author_url_column_length';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Comment Author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'comment@example.org',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -752,16 +720,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comment_submission_sends_all_expected_parameters_to_preprocess_comment_filter() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = self::factory()->user->create_and_get(
- array(
- 'role' => 'author',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = get_userdata( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get();
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Comment',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -774,7 +737,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $comment );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author' => $user->display_name,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => $user->user_email,
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_url' => $user->user_url,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -798,13 +761,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36901
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_submitting_duplicate_comments() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
- array(
- 'post_status' => 'publish',
- )
- );
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Did I say that?',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Repeat myself',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'mail@example.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,13 +777,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 36901
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_comments_flood() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
- array(
- 'post_status' => 'publish',
- )
- );
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Did I say that?',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Repeat myself',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'mail@example.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -850,13 +803,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user->ID );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = self::factory()->post->create_and_get(
- array(
- 'post_status' => 'publish',
- )
- );
</del><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_post_ID' => $post->ID,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_post_ID' => self::$post->ID,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment' => 'Did I say that?',
</span><span class="cx" style="display: block; padding: 0 10px"> 'author' => 'Repeat myself',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'mail@example.com',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -867,6 +815,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $second_comment = wp_handle_comment_submission( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $second_comment );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $post->ID, $second_comment->comment_post_ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$post->ID, $second_comment->comment_post_ID );
</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>