diff --git a/tests/phpunit/tests/ajax/MediaEdit.php b/tests/phpunit/tests/ajax/MediaEdit.php index 686dae08c5..83c478c83b 100644 --- a/tests/phpunit/tests/ajax/MediaEdit.php +++ b/tests/phpunit/tests/ajax/MediaEdit.php @@ -97,14 +97,24 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { $file_path = dirname( get_attached_file( $id ) ); + $files_that_should_not_exist = array(); + foreach ( $sizes1 as $key => $size ) { if ( $sizes2[ $key ]['file'] !== $size['file'] ) { - $files_that_shouldnt_exist[] = $file_path . '/' . $size['file']; + $files_that_should_not_exist[] = $file_path . '/' . $size['file']; } } - foreach ( $files_that_shouldnt_exist as $file ) { - $this->assertFileDoesNotExist( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' ); + if ( ! empty( $files_that_should_not_exist ) ) { + foreach ( $files_that_should_not_exist as $file ) { + $this->assertFileDoesNotExist( $file, 'IMAGE_EDIT_OVERWRITE is leaving garbage image files behind.' ); + } + } else { + /* + * This assertion will always pass due to the "if" condition, but prevents this test + * from being marked as "risky" due to the test not performing any assertions. + */ + $this->assertSame( array(), $files_that_should_not_exist ); } } }