<!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>[59729] trunk/tests/phpunit: Build/Test Tools: Add a retry mechanism for tests that perform external HTTP requests.</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/59729">59729</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/59729","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-01-29 18:17:34 +0000 (Wed, 29 Jan 2025)</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'>Build/Test Tools: Add a retry mechanism for tests that perform external HTTP requests.
While the `skipTestOnTimeout()` method will catch a timeout and prevent it from causing a test to fail, other errors such as a failed DNS lookup or HTTPS handshake can still cause a test to unnecessarily fail. This introduces a simple retry mechanism that will hopefully further reduce the flakiness of tests that perform HTTP API requests.
Fixes <a href="https://core.trac.wordpress.org/ticket/62830">#62830</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunitincludesabstracttestcasephp">trunk/tests/phpunit/includes/abstract-testcase.php</a></li>
<li><a href="#trunktestsphpunittestshttpbasephp">trunk/tests/phpunit/tests/http/base.php</a></li>
<li><a href="#trunktestsphpunittestshttpfunctionsphp">trunk/tests/phpunit/tests/http/functions.php</a></li>
<li><a href="#trunktestsphpunittestsreadmephp">trunk/tests/phpunit/tests/readme.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunitincludesabstracttestcasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/abstract-testcase.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/abstract-testcase.php 2025-01-29 18:10:47 UTC (rev 59728)
+++ trunk/tests/phpunit/includes/abstract-testcase.php 2025-01-29 18:17:34 UTC (rev 59729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1694,4 +1694,119 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> touch( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Wrapper for `wp_safe_remote_request()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_safe_remote_request( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_safe_remote_request', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_safe_remote_get()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_safe_remote_get( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_safe_remote_get', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_safe_remote_post()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_safe_remote_post( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_safe_remote_post', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_safe_remote_head()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_safe_remote_head( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_safe_remote_head', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_remote_request()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_remote_request( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_remote_request', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_remote_get()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_remote_get( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_remote_get', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_remote_post()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_remote_post( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_remote_post', $url, $args );
+ }
+
+ /**
+ * Wrapper for `wp_remote_head()` that retries on error and skips the test on timeout.
+ *
+ * @param string $url URL to retrieve.
+ * @param array $args Optional. Request arguments. Default empty array.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ protected function wp_remote_head( $url, $args = array() ) {
+ return self::retry_on_error( 'wp_remote_head', $url, $args );
+ }
+
+ /**
+ * Retries an HTTP API request up to three times and skips the test on timeout.
+ *
+ * @param callable $callback The HTTP API request function to call.
+ * @param string $url URL to retrieve.
+ * @param array $args Request arguments.
+ * @return array|WP_Error The response or WP_Error on failure.
+ */
+ private function retry_on_error( callable $callback, $url, $args ) {
+ $attempts = 0;
+
+ while ( $attempts < 3 ) {
+ $result = call_user_func( $callback, $url, $args );
+
+ if ( ! is_wp_error( $result ) ) {
+ return $result;
+ }
+
+ ++$attempts;
+ sleep( 5 );
+ }
+
+ $this->skipTestOnTimeout( $result );
+
+ return $result;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestshttpbasephp"></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/http/base.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/http/base.php 2025-01-29 18:10:47 UTC (rev 59728)
+++ trunk/tests/phpunit/tests/http/base.php 2025-01-29 18:17:34 UTC (rev 59729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,9 +44,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirect_on_301() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 5 : 5 & 301.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 200, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,9 +55,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirect_on_302() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 5 : 5 & 302.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 200, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,9 +68,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirect_on_301_no_redirect() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 5 > 0 & 301.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 301, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,9 +81,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirect_on_302_no_redirect() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 5 > 0 & 302.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 302, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,9 +92,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirections_equal() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 5 - 5.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 200, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -108,9 +103,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_no_head_redirections() {
</span><span class="cx" style="display: block; padding: 0 10px"> // No redirections on HEAD request.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 302, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -122,7 +116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirect_on_head() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Redirections on HEAD request when Requested.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request(
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->redirection_script . '?rt=' . 5,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'redirection' => 5,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,7 +124,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 200, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -140,9 +133,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirections_greater() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 10 > 5.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $res );
</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">@@ -151,9 +143,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirections_greater_edgecase() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 6 > 5 (close edge case).
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $res );
</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">@@ -162,9 +153,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirections_less_edgecase() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 4 < 5 (close edge case).
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</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">@@ -175,9 +165,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_redirections_zero_redirections_specified() {
</span><span class="cx" style="display: block; padding: 0 10px"> // 0 redirections asked for, should return the document?
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 302, (int) $res['response']['code'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -191,9 +180,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_location_header_on_201() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Prints PASS on initial load, FAIL if the client follows the specified redirection.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?201-location=true' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?201-location=true' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'PASS', $res['body'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -210,7 +198,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Test 301 - POST to POST.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'method' => 'PUT',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -218,7 +206,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $res['headers']['location'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -236,9 +223,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'test2' => 0,
</span><span class="cx" style="display: block; padding: 0 10px"> 'test3' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $this->redirection_script . '?header-check', array( 'headers' => $headers ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $this->redirection_script . '?header-check', array( 'headers' => $headers ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -267,7 +253,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_file_stream() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $this->file_stream_url;
</span><span class="cx" style="display: block; padding: 0 10px"> $size = 153204;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'stream' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,7 +267,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unlink( $res['filename'] );
</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">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', $res['body'] ); // The body should be empty.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $size, $res['headers']['Content-Length'] ); // Check the headers are returned (and the size is the same).
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -297,7 +282,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_file_stream_limited_size() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $this->file_stream_url;
</span><span class="cx" style="display: block; padding: 0 10px"> $size = 10000;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'stream' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -312,7 +297,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unlink( $res['filename'] );
</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">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,7 +312,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $url = $this->file_stream_url;
</span><span class="cx" style="display: block; padding: 0 10px"> $size = 10000;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => 30,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -336,7 +320,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $size, strlen( $res['body'] ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -354,9 +337,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_post_redirect_to_method_300( $response_code, $method ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=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">- $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $method, wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,9 +387,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'redirection' => 0,
</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">- $res = wp_remote_get( $url, $args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_get( $url, $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,11 +408,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_head( $url, $args );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_head( $url, $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> remove_filter( 'http_request_args', array( $this, 'filter_http_request_args' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $this->http_request_args['sslcertificates'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -447,9 +427,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_cookie_handling() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=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">- $res = wp_remote_get( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_get( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -467,9 +446,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->fail( 'This installation of PHP does not support SSL.' );
</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">- $res = wp_remote_get( 'https://wordpress.org/' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_get( 'https://wordpress.org/' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</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">@@ -484,9 +462,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $path = parse_url( $url, PHP_URL_PATH );
</span><span class="cx" style="display: block; padding: 0 10px"> $url = str_replace( $path, '/' . $path, $url );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $res = wp_remote_request( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = $this->wp_remote_request( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $res );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $res );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestshttpfunctionsphp"></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/http/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/http/functions.php 2025-01-29 18:10:47 UTC (rev 59728)
+++ trunk/tests/phpunit/tests/http/functions.php 2025-01-29 18:17:34 UTC (rev 59729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,9 +12,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_head_request() {
</span><span class="cx" style="display: block; padding: 0 10px"> // This URL gives a direct 200 response.
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://s.w.org/screenshots/3.9/dashboard.png';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_head( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_head( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = wp_remote_retrieve_headers( $response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,9 +30,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_head_redirect() {
</span><span class="cx" style="display: block; padding: 0 10px"> // This URL will 301 redirect.
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://wp.org/screenshots/3.9/dashboard.png';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_head( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_head( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 301, wp_remote_retrieve_response_code( $response ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,9 +41,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_head_404() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_head( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_head( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 404, wp_remote_retrieve_response_code( $response ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,9 +55,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_request() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://s.w.org/screenshots/3.9/dashboard.png';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = wp_remote_retrieve_headers( $response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,9 +76,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // This will redirect to wordpress.org.
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://wp.org/screenshots/3.9/dashboard.png';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = wp_remote_retrieve_headers( $response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,9 +96,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://wp.org/screenshots/3.9/dashboard.png';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Pretend we've already redirected 5 times.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get( $url, array( 'redirection' => -1 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get( $url, array( 'redirection' => -1 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $response );
</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">@@ -118,9 +112,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_response_cookies() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://login.wordpress.org/wp-login.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_head( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_head( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cookies = wp_remote_retrieve_cookies( $response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -152,7 +145,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_response_cookies_with_wp_http_cookie_object() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://login.wordpress.org/wp-login.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'cookies' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,7 +159,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cookies = wp_remote_retrieve_cookies( $response );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -189,7 +181,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_response_cookies_with_name_value_array() {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = 'https://login.wordpress.org/wp-login.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get(
</ins><span class="cx" style="display: block; padding: 0 10px"> $url,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'cookies' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -198,7 +190,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">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cookies = wp_remote_retrieve_cookies( $response );
</span></span></pre></div>
<a id="trunktestsphpunittestsreadmephp"></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/readme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/readme.php 2025-01-29 18:10:47 UTC (rev 59728)
+++ trunk/tests/phpunit/tests/readme.php 2025-01-29 18:17:34 UTC (rev 59729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,9 +91,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string The response body.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_response_body( $url ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $response = wp_remote_get( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $response = $this->wp_remote_get( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->skipTestOnTimeout( $response );
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotWPError( $response );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $response_code = wp_remote_retrieve_response_code( $response );
</span></span></pre>
</div>
</div>
</body>
</html>