@@ -1737,22 +1737,25 @@ Feature: Regenerate WordPress attachments
17371737
17381738 # Simulate a user edit by copying the scaled file as an "edited" version,
17391739 # updating the attached file metadata, and setting backup sizes.
1740- When I run `wp eval '
1741- $id = {ATTACHMENT_ID};
1740+ Given a simulate-edit.php file:
1741+ """
1742+ <?php
1743+ $id = (int) $args[0];
17421744 $meta = wp_get_attachment_metadata( $id );
17431745 $old_file = get_attached_file( $id );
17441746 $edited_file = preg_replace( "/(\.[^.]+)$/", "-e0000000000000$1", $old_file );
17451747 copy( $old_file, $edited_file );
17461748 $edited_relative = _wp_relative_upload_path( $edited_file );
1747- update_post_meta( $id, " _wp_attached_file" , $edited_relative );
1749+ update_post_meta( $id, ' _wp_attached_file' , $edited_relative );
17481750 $backup = array();
17491751 if ( ! empty( $meta['sizes'] ) ) {
17501752 foreach ( $meta['sizes'] as $size => $size_data ) {
17511753 $backup[ $size . '-orig' ] = $size_data;
17521754 }
17531755 }
1754- update_post_meta( $id, "_wp_attachment_backup_sizes" , $backup );
1755- '`
1756+ update_post_meta( $id, '_wp_attachment_backup_sizes', $backup );
1757+ """
1758+ When I run `wp eval-file simulate-edit.php {ATTACHMENT_ID}`
17561759 Then the wp-content/uploads/large-image-scaled-e0000000000000.jpg file should exist
17571760
17581761 When I run `wp post meta get {ATTACHMENT_ID} _wp_attached_file`
0 commit comments