Make WordPress Core


Ignore:
Timestamp:
11/09/2020 01:16:54 PM (5 years ago)
Author:
johnbillion
Message:

Media: Restore the ability of WP_Image_Editor_Imagick->save() to create a missing directory when needed.

Props eemitch, mikeschroder, hellofromTonya, p00ya, johnbillion

Fixes #51665

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/editorImagick.php

    r49488 r49542  
    598598        unlink( $temp_file );
    599599    }
     600
     601    /**
     602     * @ticket 51665
     603     */
     604    public function test_directory_creation() {
     605        $file      = realpath( DIR_TESTDATA ) . '/images/a2-small.jpg';
     606        $directory = realpath( DIR_TESTDATA ) . '/images/nonexistent-directory';
     607        $editor    = new WP_Image_Editor_Imagick( $file );
     608
     609        $this->assertFileNotExists( $directory );
     610
     611        $loaded = $editor->load();
     612        $this->assertNotWPError( $loaded );
     613
     614        $resized = $editor->resize( 100, 100, true );
     615        $this->assertNotWPError( $resized );
     616
     617        $saved = $editor->save( $directory . '/a2-small-cropped.jpg' );
     618        $this->assertNotWPError( $saved );
     619
     620        unlink( $directory . '/a2-small-cropped.jpg' );
     621        rmdir( $directory );
     622    }
    600623}
Note: See TracChangeset for help on using the changeset viewer.