mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
REST API: Ensure attachments created with WP_REST_Attachments_Controller::create_item() on Windows have a relative path.
Props ocean90, SergeyBiryukov, redcastor. Fixes #40861. git-svn-id: https://develop.svn.wordpress.org/trunk@43529 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -773,6 +773,20 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$this->assertEquals( '', $attachment['alt_text'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 40861
|
||||
*/
|
||||
public function test_create_item_ensure_relative_path() {
|
||||
wp_set_current_user( self::$author_id );
|
||||
$request = new WP_REST_Request( 'POST', '/wp/v2/media' );
|
||||
$request->set_header( 'Content-Type', 'image/jpeg' );
|
||||
$request->set_header( 'Content-Disposition', 'attachment; filename=canola.jpg' );
|
||||
$request->set_body( file_get_contents( $this->test_file ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$attachment = $response->get_data();
|
||||
$this->assertNotContains( ABSPATH, get_post_meta( $attachment['id'], '_wp_attached_file', true ) );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
$attachment_id = $this->factory->attachment->create_object(
|
||||
|
||||
Reference in New Issue
Block a user