diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 35090e2288..a4e4e810df 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -2532,7 +2532,7 @@ function wp_ajax_upload_attachment() { check_ajax_referer( 'media-form' ); /* * This function does not use wp_send_json_success() / wp_send_json_error() - * as the html4 Plupload handler requires a text/html content-type for older IE. + * as the html4 Plupload handler requires a text/html Content-Type for older IE. * See https://core.trac.wordpress.org/ticket/31037 */ diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index 62e9c0cb91..6d22898b9c 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1184,7 +1184,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) { return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data ); } - $content_disposition = wp_remote_retrieve_header( $response, 'content-disposition' ); + $content_disposition = wp_remote_retrieve_header( $response, 'Content-Disposition' ); if ( $content_disposition ) { $content_disposition = strtolower( $content_disposition ); @@ -1211,7 +1211,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) { } } - $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); + $content_md5 = wp_remote_retrieve_header( $response, 'Content-MD5' ); if ( $content_md5 ) { $md5_check = verify_file_md5( $tmpfname, $content_md5 ); @@ -1238,7 +1238,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) { // Perform signature valiation if supported. if ( $signature_verification ) { - $signature = wp_remote_retrieve_header( $response, 'x-content-signature' ); + $signature = wp_remote_retrieve_header( $response, 'X-Content-Signature' ); if ( ! $signature ) { // Retrieve signatures from a file if the header wasn't included. diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 63580cceb0..9c4cb43580 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -512,7 +512,7 @@ function wp_install_maybe_enable_pretty_permalinks() { * can block head requests. */ $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); - $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); + $x_pingback_header = wp_remote_retrieve_header( $response, 'X-Pingback' ); $pretty_permalinks = $x_pingback_header && get_bloginfo( 'pingback_url' ) === $x_pingback_header; if ( $pretty_permalinks ) { diff --git a/src/wp-includes/class-json.php b/src/wp-includes/class-json.php index d651dcdfb8..6091d567f5 100644 --- a/src/wp-includes/class-json.php +++ b/src/wp-includes/class-json.php @@ -291,7 +291,7 @@ class Services_JSON { _deprecated_function( __METHOD__, '5.3.0', 'The PHP native JSON extension' ); - header('Content-type: application/json'); + header('Content-Type: application/json'); return $this->encodeUnsafe($var); } /** diff --git a/src/wp-includes/class-simplepie.php b/src/wp-includes/class-simplepie.php index a392e54cd9..3d639fc709 100644 --- a/src/wp-includes/class-simplepie.php +++ b/src/wp-includes/class-simplepie.php @@ -1864,7 +1864,7 @@ class SimplePie } /** - * Send the content-type header with correct encoding + * Send the Content-Type header with correct encoding * * This method ensures that the SimplePie-enabled page is being served with * the correct {@link http://www.iana.org/assignments/media-types/ mime-type} @@ -1886,7 +1886,7 @@ class SimplePie { if (!headers_sent()) { - $header = "Content-type: $mime;"; + $header = "Content-Type: $mime;"; if ($this->get_encoding()) { $header .= ' charset=' . $this->get_encoding(); diff --git a/src/wp-includes/class-snoopy.php b/src/wp-includes/class-snoopy.php index fb6857c525..e82c673989 100644 --- a/src/wp-includes/class-snoopy.php +++ b/src/wp-includes/class-snoopy.php @@ -53,7 +53,7 @@ class Snoopy var $cookies = array(); // array of cookies to pass // $cookies["username"]="joe"; var $rawheaders = array(); // array of raw headers to send - // $rawheaders["Content-type"]="text/html"; + // $rawheaders["Content-Type"]="text/html"; var $maxredirs = 5; // http redirection depth maximum. 0 = disallow var $lastredirectaddr = ""; // contains address of last redirected address @@ -825,13 +825,13 @@ class Snoopy $headers .= $headerKey.": ".$headerVal."\r\n"; } if(!empty($content_type)) { - $headers .= "Content-type: $content_type"; + $headers .= "Content-Type: $content_type"; if ($content_type == "multipart/form-data") $headers .= "; boundary=".$this->_mime_boundary; $headers .= "\r\n"; } if(!empty($body)) - $headers .= "Content-length: ".strlen($body)."\r\n"; + $headers .= "Content-Length: ".strlen($body)."\r\n"; if(!empty($this->user) || !empty($this->pass)) $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; @@ -990,12 +990,12 @@ class Snoopy } if(!empty($content_type)) { if ($content_type == "multipart/form-data") - $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; + $headers[] = "Content-Type: $content_type; boundary=".$this->_mime_boundary; else - $headers[] = "Content-type: $content_type"; + $headers[] = "Content-Type: $content_type"; } if(!empty($body)) - $headers[] = "Content-length: ".strlen($body); + $headers[] = "Content-Length: ".strlen($body); if(!empty($this->user) || !empty($this->pass)) $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index a52edf84f4..50a761f94a 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2824,12 +2824,12 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { return false; } - if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) { - return wp_remote_retrieve_header( $response, 'x-pingback' ); + if ( wp_remote_retrieve_header( $response, 'X-Pingback' ) ) { + return wp_remote_retrieve_header( $response, 'X-Pingback' ); } // Not an (x)html, sgml, or xml page, no use going further. - if ( preg_match( '#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' ) ) ) { + if ( preg_match( '#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'Content-Type' ) ) ) { return false; } diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 623a69aba0..1d285b6cf7 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -943,8 +943,8 @@ function do_enclose( $content, $post ) { $headers = wp_get_http_headers( $url ); if ( $headers ) { - $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; - $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; + $len = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0; + $type = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : ''; $allowed_types = array( 'video', 'audio' ); // Check to see if we can figure out the mime type from the extension. diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index ba5e89737c..5f234f47a2 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -755,7 +755,7 @@ function bloginfo( $show = '' ) { * - 'admin_email' - Admin email (set in Settings > General) * - 'charset' - The "Encoding for pages and feeds" (set in Settings > Reading) * - 'version' - The current WordPress version - * - 'html_type' - The content-type (default: "text/html"). Themes and plugins + * - 'html_type' - The Content-Type (default: "text/html"). Themes and plugins * can override the default value using the {@see 'pre_option_html_type'} filter * - 'text_direction' - The text direction determined by the site's language. is_rtl() * should be used instead diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index a3cb0408b4..dded2fee86 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -463,7 +463,7 @@ if ( ! function_exists( 'wp_mail' ) ) : // Set Content-Type and charset. - // If we don't have a content-type from the input headers. + // If we don't have a Content-Type from the input headers. if ( ! isset( $content_type ) ) { $content_type = 'text/plain'; } diff --git a/src/wp-includes/rest-api/class-wp-rest-request.php b/src/wp-includes/rest-api/class-wp-rest-request.php index 494abd2360..18e867de3a 100644 --- a/src/wp-includes/rest-api/class-wp-rest-request.php +++ b/src/wp-includes/rest-api/class-wp-rest-request.php @@ -291,16 +291,16 @@ class WP_REST_Request implements ArrayAccess { } /** - * Retrieves the content-type of the request. + * Retrieves the Content-Type of the request. * * @since 4.4.0 * * @return array|null Map containing 'value' and 'parameters' keys - * or null when no valid content-type header was + * or null when no valid Content-Type header was * available. */ public function get_content_type() { - $value = $this->get_header( 'content-type' ); + $value = $this->get_header( 'Content-Type' ); if ( empty( $value ) ) { return null; } @@ -325,11 +325,11 @@ class WP_REST_Request implements ArrayAccess { } /** - * Checks if the request has specified a JSON content-type. + * Checks if the request has specified a JSON Content-Type. * * @since 5.6.0 * - * @return bool True if the content-type header is JSON. + * @return bool True if the Content-Type header is JSON. */ public function is_json_content_type() { $content_type = $this->get_content_type(); @@ -719,7 +719,7 @@ class WP_REST_Request implements ArrayAccess { $this->parsed_body = true; /* - * Check that we got URL-encoded. Treat a missing content-type as + * Check that we got URL-encoded. Treat a missing Content-Type as * URL-encoded for maximum compatibility. */ $content_type = $this->get_content_type(); diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php b/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php index 11d5c3820a..9f91a10b7c 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php @@ -123,7 +123,7 @@ class WP_Sitemaps_Renderer { * @param array $sitemaps Array of sitemap URLs. */ public function render_index( $sitemaps ) { - header( 'Content-type: application/xml; charset=UTF-8' ); + header( 'Content-Type: application/xml; charset=UTF-8' ); $this->check_for_simple_xml_availability(); @@ -188,7 +188,7 @@ class WP_Sitemaps_Renderer { * @param array $url_list Array of URLs for a sitemap. */ public function render_sitemap( $url_list ) { - header( 'Content-type: application/xml; charset=UTF-8' ); + header( 'Content-Type: application/xml; charset=UTF-8' ); $this->check_for_simple_xml_availability(); diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php b/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php index 8268fcc924..f752a7f55f 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php @@ -22,7 +22,7 @@ class WP_Sitemaps_Stylesheet { * @param string $type Stylesheet type. Either 'sitemap' or 'index'. */ public function render_stylesheet( $type ) { - header( 'Content-type: application/xml; charset=UTF-8' ); + header( 'Content-Type: application/xml; charset=UTF-8' ); if ( 'sitemap' === $type ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All content escaped below. diff --git a/src/wp-mail.php b/src/wp-mail.php index 631645cbed..2600521e38 100644 --- a/src/wp-mail.php +++ b/src/wp-mail.php @@ -171,7 +171,7 @@ for ( $i = 1; $i <= $count; $i++ ) { $content = explode( '--' . $boundary, $content ); $content = $content[2]; - // Match case-insensitive content-transfer-encoding. + // Match case-insensitive Content-Transfer-Encoding. if ( preg_match( '/Content-Transfer-Encoding: quoted-printable/i', $content, $delim ) ) { $content = explode( $delim[0], $content ); $content = $content[1]; diff --git a/tests/phpunit/data/WPHTTP-testcase-redirection-script.php b/tests/phpunit/data/WPHTTP-testcase-redirection-script.php index a73e8c6e09..94643d3de9 100644 --- a/tests/phpunit/data/WPHTTP-testcase-redirection-script.php +++ b/tests/phpunit/data/WPHTTP-testcase-redirection-script.php @@ -36,7 +36,7 @@ if ( isset($_GET['201-location']) ) { } if ( isset($_GET['header-check']) ) { $out = array(); - header("Content-type: text/plain"); + header("Content-Type: text/plain"); foreach ( $_SERVER as $key => $value ) { if ( stripos($key, 'http') === 0 ) { $key = strtolower(substr($key, 5)); @@ -63,7 +63,7 @@ if ( isset( $_GET['post-redirect-to-method'] ) ) { echo $method; exit; - + } if ( isset( $_GET['location-with-200'] ) ) { diff --git a/tests/phpunit/tests/admin/includesFile.php b/tests/phpunit/tests/admin/includesFile.php index 5ff28ba90c..375f895c84 100644 --- a/tests/phpunit/tests/admin/includesFile.php +++ b/tests/phpunit/tests/admin/includesFile.php @@ -156,7 +156,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'attachment; filename="filename-from-content-disposition-header.txt"', + 'Content-Disposition' => 'attachment; filename="filename-from-content-disposition-header.txt"', ), ); } @@ -174,7 +174,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'attachment; filename="../../filename-from-content-disposition-header.txt"', + 'Content-Disposition' => 'attachment; filename="../../filename-from-content-disposition-header.txt"', ), ); } @@ -192,7 +192,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'attachment; filename=filename-from-content-disposition-header.txt', + 'Content-Disposition' => 'attachment; filename=filename-from-content-disposition-header.txt', ), ); } @@ -241,7 +241,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'filename="filename-from-content-disposition-header.txt"', + 'Content-Disposition' => 'filename="filename-from-content-disposition-header.txt"', ), ); } @@ -259,7 +259,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'inline; filename="filename-from-content-disposition-header.txt"', + 'Content-Disposition' => 'inline; filename="filename-from-content-disposition-header.txt"', ), ); } @@ -277,7 +277,7 @@ class Tests_Admin_IncludesFile extends WP_UnitTestCase { 'code' => 200, ), 'headers' => array( - 'content-disposition' => 'form-data; name="file"; filename="filename-from-content-disposition-header.txt"', + 'Content-Disposition' => 'form-data; name="file"; filename="filename-from-content-disposition-header.txt"', ), ); } diff --git a/tests/phpunit/tests/functions/doEnclose.php b/tests/phpunit/tests/functions/doEnclose.php index 5fe48b3554..4d1a2ee818 100644 --- a/tests/phpunit/tests/functions/doEnclose.php +++ b/tests/phpunit/tests/functions/doEnclose.php @@ -265,8 +265,8 @@ class Tests_Functions_DoEnclose extends WP_UnitTestCase { $fake_headers = array( 'mp4' => array( 'headers' => array( - 'content-length' => 123, - 'content-type' => 'video/mp4', + 'Content-Length' => 123, + 'Content-Type' => 'video/mp4', ), ), 'ogg' => array( @@ -289,8 +289,8 @@ class Tests_Functions_DoEnclose extends WP_UnitTestCase { // Fallback header. return array( 'headers' => array( - 'content-length' => 0, - 'content-type' => '', + 'Content-Length' => 0, + 'Content-Type' => '', ), ); } diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index ad104afe52..ad487e3f19 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -283,7 +283,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); $this->assertSame( '', $res['body'] ); // The body should be empty. - $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same). + $this->assertEquals( $size, $res['headers']['Content-Length'] ); // Check the headers are returned (and the size is the same). $this->assertSame( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp directory. } diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 5aa92fdf50..cb0045fd50 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -20,8 +20,8 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $this->assertIsArray( $response ); - $this->assertSame( 'image/jpeg', $headers['content-type'] ); - $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 'image/jpeg', $headers['Content-Type'] ); + $this->assertSame( '40148', $headers['Content-Length'] ); $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } @@ -65,8 +65,8 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $this->assertIsArray( $response ); // Should return the same headers as a HEAD request. - $this->assertSame( 'image/jpeg', $headers['content-type'] ); - $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 'image/jpeg', $headers['Content-Type'] ); + $this->assertSame( '40148', $headers['Content-Length'] ); $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } @@ -86,8 +86,8 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $headers = wp_remote_retrieve_headers( $response ); // Should return the same headers as a HEAD request. - $this->assertSame( 'image/jpeg', $headers['content-type'] ); - $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 'image/jpeg', $headers['Content-Type'] ); + $this->assertSame( '40148', $headers['Content-Length'] ); $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } diff --git a/tests/phpunit/tests/post/wpAfterInsertPost.php b/tests/phpunit/tests/post/wpAfterInsertPost.php index c81ad21387..f184c66e01 100644 --- a/tests/phpunit/tests/post/wpAfterInsertPost.php +++ b/tests/phpunit/tests/post/wpAfterInsertPost.php @@ -171,7 +171,7 @@ class Tests_Post_wpAfterInsertPost extends WP_UnitTestCase { $post_id = self::$post_id; $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( array( 'title' => 'new title' ) ); rest_get_server()->dispatch( $request ); @@ -188,7 +188,7 @@ class Tests_Post_wpAfterInsertPost extends WP_UnitTestCase { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', sprintf( '/wp/v2/posts' ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( array( 'title' => 'new title', @@ -211,7 +211,7 @@ class Tests_Post_wpAfterInsertPost extends WP_UnitTestCase { $attachment_id = self::$attachment_id; $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/media/%d', $attachment_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( array( 'title' => 'new attachment title' ) ); rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index 32ba9768e7..4f71ca0269 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -311,7 +311,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_post_data( array( @@ -327,7 +327,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle public function test_update_item() { wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_post_data( array( @@ -346,7 +346,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$contributor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_post_data( array( @@ -365,7 +365,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $current_post = get_post( self::$post_id ); @@ -412,7 +412,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $autosave_data ) ); $response = rest_get_server()->dispatch( $request ); @@ -451,7 +451,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $autosave_data ) ); $response = rest_get_server()->dispatch( $request ); @@ -572,7 +572,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle public function test_update_item_draft_page_with_parent() { wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$child_draft_page_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_post_data( array( @@ -593,7 +593,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . self::$draft_page_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_post_data( array( @@ -648,7 +648,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle // Initiate an autosave via the REST API as Gutenberg does. $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $autosave_data ) ); $response = rest_get_server()->dispatch( $request ); @@ -699,7 +699,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle // Create autosaves response. $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $post_id . '/autosaves' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $autosave_data ) ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 71d02d4832..3cd165dbbf 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -501,7 +501,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $attributes = array( 'some_string' => $string_attribute ); $request = new WP_REST_Request( 'POST', self::$rest_api_route . self::$block_name ); $request->set_param( 'context', 'edit' ); - $request->set_header( 'content-type', 'application/json' ); + $request->set_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( compact( 'attributes' ) ) ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 2726ce68c9..9258756a73 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -1133,7 +1133,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1239,7 +1239,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1264,7 +1264,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1287,7 +1287,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1307,7 +1307,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1327,7 +1327,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1347,7 +1347,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1365,7 +1365,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1386,7 +1386,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1413,7 +1413,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1435,7 +1435,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1460,7 +1460,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1481,7 +1481,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1510,7 +1510,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 201, $response->get_status() ); @@ -1536,7 +1536,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1575,7 +1575,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1598,7 +1598,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1625,7 +1625,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1654,7 +1654,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1679,7 +1679,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1699,7 +1699,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1720,7 +1720,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1744,7 +1744,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1768,8 +1768,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); - $request->add_header( 'user_agent', 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)' ); + $request->add_header( 'Content-Type', 'application/json' ); + $request->add_header( 'User_Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1794,7 +1794,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 'status' => 'approved', ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -1815,7 +1815,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase 'status' => 'approved', ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1835,7 +1835,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_comment_invalid_author_ip', $response, 403 ); @@ -1855,7 +1855,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -1875,7 +1875,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1895,7 +1895,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1915,7 +1915,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1935,7 +1935,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1955,7 +1955,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1976,7 +1976,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1996,7 +1996,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2023,7 +2023,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2044,7 +2044,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2075,7 +2075,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2093,7 +2093,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2117,7 +2117,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2132,7 +2132,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2156,7 +2156,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2183,7 +2183,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2207,7 +2207,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2231,7 +2231,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2255,7 +2255,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2275,7 +2275,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2296,7 +2296,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 201, $response->get_status() ); @@ -2319,7 +2319,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2424,7 +2424,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2452,7 +2452,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $comment_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2474,7 +2474,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2498,7 +2498,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2518,7 +2518,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2537,7 +2537,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2557,7 +2557,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2575,7 +2575,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2592,7 +2592,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2609,7 +2609,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2630,7 +2630,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2646,7 +2646,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2661,7 +2661,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', '/wp/v2/comments/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2686,7 +2686,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2705,7 +2705,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2735,7 +2735,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $private_comment_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2794,7 +2794,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2814,7 +2814,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2834,7 +2834,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2853,7 +2853,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2874,7 +2874,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-request.php b/tests/phpunit/tests/rest-api/rest-request.php index 509c754f65..cf1f3ac739 100644 --- a/tests/phpunit/tests/rest-api/rest-request.php +++ b/tests/phpunit/tests/rest-api/rest-request.php @@ -203,7 +203,7 @@ class Tests_REST_Request extends WP_UnitTestCase { * @ticket 49404 * @dataProvider alternate_json_content_type_provider * - * @param string $content_type The content-type header. + * @param string $content_type The Content-Type header. * @param string $source The source value. * @param bool $accept_json The accept_json value. */ @@ -234,7 +234,7 @@ class Tests_REST_Request extends WP_UnitTestCase { * @ticket 49404 * @dataProvider is_json_content_type_provider * - * @param string $content_type The content-type header. + * @param string $content_type The Content-Type header. * @param bool $is_json The is_json value. */ public function test_is_json_content_type( $content_type, $is_json ) { @@ -242,7 +242,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_header( 'Content-Type', $content_type ); - // Check for JSON content-type. + // Check for JSON Content-Type. $this->assertSame( $is_json, $this->request->is_json_content_type() ); } @@ -361,7 +361,7 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $this->request->set_method( 'PUT' ); - $this->request->add_header( 'content-type', 'application/json' ); + $this->request->add_header( 'Content-Type', 'application/json' ); $this->request->set_body( wp_json_encode( $data ) ); foreach ( $data as $key => $expected_value ) { @@ -383,7 +383,7 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $this->request->set_method( 'POST' ); - $this->request->add_header( 'content-type', 'application/json' ); + $this->request->add_header( 'Content-Type', 'application/json' ); $this->request->set_body( wp_json_encode( $data ) ); foreach ( $data as $key => $expected_value ) { @@ -864,7 +864,7 @@ class Tests_REST_Request extends WP_UnitTestCase { public function test_set_param_follows_parameter_order() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( wp_json_encode( @@ -892,7 +892,7 @@ class Tests_REST_Request extends WP_UnitTestCase { */ public function test_set_param_updates_param_in_json_and_query() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( wp_json_encode( @@ -919,7 +919,7 @@ class Tests_REST_Request extends WP_UnitTestCase { */ public function test_set_param_updates_param_if_already_exists_in_query() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( wp_json_encode( @@ -953,7 +953,7 @@ class Tests_REST_Request extends WP_UnitTestCase { */ public function test_set_param_to_null_updates_param_in_json_and_query() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( wp_json_encode( @@ -980,7 +980,7 @@ class Tests_REST_Request extends WP_UnitTestCase { */ public function test_set_param_from_null_updates_param_in_json_and_query_with_null() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( wp_json_encode( @@ -1007,7 +1007,7 @@ class Tests_REST_Request extends WP_UnitTestCase { */ public function test_set_param_with_invalid_json() { $request = new WP_REST_Request(); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_method( 'POST' ); $request->set_body( '' ); $request->set_param( 'param', 'value' ); diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index 60a5f28c8d..a2bbcb79c6 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -773,7 +773,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase ), ); $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $data ) ); $response = rest_do_request( $request ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 1187120343..2bb64b5ff2 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -1230,7 +1230,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1263,7 +1263,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); @@ -1308,7 +1308,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1338,7 +1338,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -1369,7 +1369,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { add_filter( 'can_add_user_to_blog', '__return_false' ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'user_cannot_be_added', $response ); @@ -1392,7 +1392,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { switch_to_blog( self::$site ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -1422,7 +1422,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); @@ -1431,7 +1431,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { switch_to_blog( self::$site ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $switched_response = rest_get_server()->dispatch( $request ); @@ -1470,7 +1470,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -1487,7 +1487,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1507,7 +1507,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1526,7 +1526,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1546,7 +1546,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'POST', '/wp/v2/users' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1579,7 +1579,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $_POST['locale'] = 'de_DE'; $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $_POST ); $response = rest_get_server()->dispatch( $request ); @@ -1826,7 +1826,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $pw_before = $userdata->user_pass; $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) ); - $request->add_header( 'content-type', 'application/json' ); + $request->add_header( 'Content-Type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); @@ -2008,14 +2008,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$user ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_cannot_edit', $response, 403 ); $request = new WP_REST_Request( 'PUT', '/wp/v2/users/me' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -2035,7 +2035,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -2892,7 +2892,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$user ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( array( 'first_name' => 'New Name' ) ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 ); @@ -2914,7 +2914,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$superadmin ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $request->set_body_params( array( 'first_name' => 'New Name' ) ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_user_invalid_id', $response, 404 ); diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php index be9fdbdcf5..2d29748967 100644 --- a/tests/phpunit/tests/rest-api/rest-widgets-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widgets-controller.php @@ -412,7 +412,7 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { public function mocked_rss_response() { $single_value_headers = array( - 'content-type' => 'application/rss+xml; charset=UTF-8', + 'Content-Type' => 'application/rss+xml; charset=UTF-8', 'link' => '; rel="https://api.w.org/"', ); diff --git a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php index 5eecd99d43..22ca3a830c 100644 --- a/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php +++ b/tests/phpunit/tests/rest-api/wpRestMenuItemsController.php @@ -318,7 +318,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data(); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -334,7 +334,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menus' => array( 123, 456 ), @@ -354,7 +354,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'taxonomy', @@ -377,7 +377,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro $actual = array(); for ( $i = 1; $i < 5; $i++ ) { $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menu_order' => $i, @@ -404,7 +404,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro $new_menu_id = wp_create_nav_menu( rand_str() ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menu_order' => 0, @@ -416,7 +416,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menu_order' => 1, @@ -436,7 +436,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $new_menu_id = wp_create_nav_menu( rand_str() ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menu_order' => 'ddddd', @@ -456,7 +456,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $new_menu_id = wp_create_nav_menu( rand_str() ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menu_order' => -9, @@ -476,7 +476,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); wp_create_nav_menu( rand_str() ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'parent' => -9, @@ -494,7 +494,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro public function test_create_item_invalid_menu() { wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'menus' => -9, @@ -513,7 +513,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'post_type', @@ -533,7 +533,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'post_type_archive', @@ -553,7 +553,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'custom', @@ -573,7 +573,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'custom', @@ -593,7 +593,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'type' => 'custom', @@ -615,7 +615,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/menu-items/%d', $this->menu_item_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'xfn' => array( 'test1', 'test2', 'test3' ), @@ -648,7 +648,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro $good_data = array( 'test1', 'test2', 'test3', 'test4' ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/menu-items/%d', $this->menu_item_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data( array( 'xfn' => $bad_data, @@ -680,7 +680,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro $post_id = self::factory()->post->create(); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/menu-items/%d', $post_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $params = $this->set_menu_item_data(); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); @@ -1021,7 +1021,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/menu-items' ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $parameters = $this->set_menu_item_data( array( 'title' => 'Some \\\'title', @@ -1043,7 +1043,7 @@ class Tests_REST_WpRestMenuItemsController extends WP_Test_REST_Post_Type_Contro wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/menu-items/%d', $this->menu_item_id ) ); - $request->add_header( 'content-type', 'application/x-www-form-urlencoded' ); + $request->add_header( 'Content-Type', 'application/x-www-form-urlencoded' ); $title = 'Some \\\'title'; $params = $this->set_menu_item_data( array( diff --git a/tests/phpunit/tests/widgets/wpWidgetRss.php b/tests/phpunit/tests/widgets/wpWidgetRss.php index 424969c126..7135e4b702 100644 --- a/tests/phpunit/tests/widgets/wpWidgetRss.php +++ b/tests/phpunit/tests/widgets/wpWidgetRss.php @@ -101,7 +101,7 @@ class Tests_Widgets_wpWidgetRss extends WP_UnitTestCase { public function mocked_rss_response() { $single_value_headers = array( - 'content-type' => 'application/rss+xml; charset=UTF-8', + 'Content-Type' => 'application/rss+xml; charset=UTF-8', 'link' => '; rel="https://api.w.org/"', );