mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
HTTP API: Fix request header inconsistencies.
This changeset improves the consistency in capitalization of fetching and outputting of request headers. It also updates occurrences found in some docblocks. Props johnjamesjacoby, costdev, audrasjb, petitphp, mhkuu, SergeyBiryukov. Fixes #54225. git-svn-id: https://develop.svn.wordpress.org/trunk@55210 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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'] ) ) {
|
||||
|
||||
@@ -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"',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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' => '<https://wordpress.org/news/wp-json/>; rel="https://api.w.org/"',
|
||||
);
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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' => '<https://wordpress.org/news/wp-json/>; rel="https://api.w.org/"',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user