Skip to content

Commit 5e793e5

Browse files
committed
Tests: Use a file path for cropped site icon attachments.
Copy the parent image into the uploads directory and pass the resulting file path to WP_Site_Icon::insert_attachment(), matching the production call. Assert that the copy succeeds before inserting the attachment. This prevents attachment metadata generation from opening a URL over HTTP and waiting for socket timeouts when the test domain includes a port. Developed in: #13661 Props lucatume, adrianmoldovanwp. Fixes #66159. git-svn-id: https://develop.svn.wordpress.org/trunk@63874 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a17e87d commit 5e793e5

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎tests/phpunit/tests/image/siteIcon.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ public function test_additional_sizes_generate_square_subsizes() {
136136

137137
public function test_insert_cropped_attachment() {
138138
$attachment_id = $this->insert_attachment();
139-
$parent_url = get_post( $attachment_id )->guid;
140-
$cropped = str_replace( wp_basename( $parent_url ), 'cropped-test-image.jpg', $parent_url );
139+
$parent_file = get_attached_file( $attachment_id );
140+
$cropped = str_replace( wp_basename( $parent_file ), 'cropped-test-image.jpg', $parent_file );
141+
$this->assertTrue( copy( $parent_file, $cropped ), 'Failed to copy the image for the cropped attachment.' );
141142

142143
$object = wp_copy_parent_attachment_properties( $cropped, $attachment_id, 'site-icon' );
143144
$cropped_id = $this->wp_site_icon->insert_attachment( $object, $cropped );

0 commit comments

Comments
 (0)