You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 92eb256
Browse filesBrowse the repository at this point in the historyBrowse files
Tests: Cover attachment field inheritance when editing images.
Verify that edited attachments inherit omitted title, caption, description, and alt text from the original. Cover absent alt metadata and requests that override selected fields while inheriting the others.
Developed in: #14893
Props irozum.
See #50675.
git-svn-id: https://develop.svn.wordpress.org/trunk@65089 602fd350-edb4-49c9-b593-d223f7449a82
Copy file name to clipboardExpand all lines: tests/phpunit/tests/rest-api/rest-attachments-controller.php
+118Lines changed: 118 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3751,6 +3751,124 @@ public function test_edit_image_updates_attachment_fields() {
3751
3751
$this->assertSame( 'Test Alt Text', get_post_meta( $new_attachment_id, '_wp_attachment_image_alt', true ), 'Alt text of the updated attachment is not identical.' );
3752
3752
}
3753
3753
3754
+
/**
3755
+
* Tests that an edited image inherits the title, caption, description and alt text of the original attachment.
$this->assertNotSame( $attachment, $new_attachment_id, 'A new attachment should have been created.' );
3767
+
$this->assertSame( 'Original Title', $new_attachment->post_title, 'Title was not copied from the original attachment.' );
3768
+
$this->assertSame( 'Original Caption', $new_attachment->post_excerpt, 'Caption was not copied from the original attachment.' );
3769
+
$this->assertSame( 'Original Description', $new_attachment->post_content, 'Description was not copied from the original attachment.' );
3770
+
$this->assertSame( 'Original Alt Text', get_post_meta( $new_attachment_id, '_wp_attachment_image_alt', true ), 'Alt text was not copied from the original attachment.' );
3771
+
}
3772
+
3773
+
/**
3774
+
* Tests that no alt text meta is created for an edited image when the original attachment has none.
$this->assertFalse( metadata_exists( 'post', $new_attachment_id, '_wp_attachment_image_alt' ), 'Alt text meta should not exist when the original has none.' );
3785
+
}
3786
+
3787
+
/**
3788
+
* Tests that fields passed in the request take precedence over the original attachment, while omitted fields are still inherited.
0 commit comments