mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Clean up test image before performing assertions in image tests.
This makes sure there are no leftover images in case of a test failure. Applies to: `test_wp_calculate_image_srcset_no_date_uploads()`. Includes renaming the `$int` variable to `$int_size` for consistency with some other tests. Follow-up to [34855], [35412], [35751], [53463]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53920 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3e740230c3
commit
4bfbe07a89
@ -1653,11 +1653,11 @@ EOF;
|
||||
|
||||
$expected = trim( $expected, ' ,' );
|
||||
|
||||
foreach ( $intermediates as $int ) {
|
||||
$image_url = wp_get_attachment_image_url( self::$large_id, $int );
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int );
|
||||
foreach ( $intermediates as $int_size ) {
|
||||
$image_url = wp_get_attachment_image_url( self::$large_id, $int_size );
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int_size );
|
||||
|
||||
if ( 'full' === $int ) {
|
||||
if ( 'full' === $int_size ) {
|
||||
// Add the full size image. Expected to be in the srcset when the full size image is used as src.
|
||||
$_expected = $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w, ' . $expected;
|
||||
} else {
|
||||
@ -1706,11 +1706,19 @@ EOF;
|
||||
|
||||
$expected = trim( $expected, ' ,' );
|
||||
|
||||
foreach ( $intermediates as $int ) {
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int );
|
||||
$image_url = wp_get_attachment_image_url( $id, $int );
|
||||
foreach ( $intermediates as $int_size ) {
|
||||
$image_urls[ $int_size ] = wp_get_attachment_image_url( $id, $int_size );
|
||||
}
|
||||
|
||||
if ( 'full' === $int ) {
|
||||
// Remove the attachment.
|
||||
wp_delete_attachment( $id, true );
|
||||
remove_filter( 'upload_dir', '_upload_dir_no_subdir' );
|
||||
|
||||
foreach ( $intermediates as $int_size ) {
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int_size );
|
||||
$image_url = $image_urls[ $int_size ];
|
||||
|
||||
if ( 'full' === $int_size ) {
|
||||
// Add the full size image. Expected to be in the srcset when the full size image is used as src.
|
||||
$_expected = $uploads_dir_url . $image_meta['file'] . ' ' . $image_meta['width'] . 'w, ' . $expected;
|
||||
} else {
|
||||
@ -1721,9 +1729,6 @@ EOF;
|
||||
$this->assertSame( $expected_srcset, wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) );
|
||||
}
|
||||
|
||||
// Remove the attachment.
|
||||
wp_delete_attachment( $id, true );
|
||||
remove_filter( 'upload_dir', '_upload_dir_no_subdir' );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1796,11 +1801,11 @@ EOF;
|
||||
// Prepend an absolute path to simulate a pre-2.7 upload.
|
||||
$image_meta['file'] = 'H:\home\wordpress\trunk/wp-content/uploads/' . $image_meta['file'];
|
||||
|
||||
foreach ( $intermediates as $int ) {
|
||||
$image_url = wp_get_attachment_image_url( self::$large_id, $int );
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int );
|
||||
foreach ( $intermediates as $int_size ) {
|
||||
$image_url = wp_get_attachment_image_url( self::$large_id, $int_size );
|
||||
$size_array = $this->get_image_size_array_from_meta( $image_meta, $int_size );
|
||||
|
||||
if ( 'full' === $int ) {
|
||||
if ( 'full' === $int_size ) {
|
||||
// Add the full size image. Expected to be in the srcset when the full size image is used as src.
|
||||
$_expected = $uploads_dir_url . $full_size_file . ' ' . $image_meta['width'] . 'w, ' . $expected;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user