Make WordPress Core

Changeset 55066


Ignore:
Timestamp:
01/14/2023 02:06:02 AM (22 months ago)
Author:
SergeyBiryukov
Message:

Tests: Move the test for wp_save_image_file() with a GD resource to a more appropriate place.

When passed a GD resource as $image, wp_save_image_file() should throw a deprecated argument notice:

Function wp_save_image_file was called with an argument that is deprecated since version 3.5.0!
$image needs to be a WP_Image_Editor object.

The test verifies that the notice is thrown as expected.

Includes:

  • Removing the Tests_Functions_Deprecated class. It appears to be initially intended for testing deprecated functions or arguments, but this was later superseded by the @expectedDeprecated annotation.
  • Removing a redundant test for wp_save_image_file() not throwing a deprecation notice when passed a WP_Image_Editor instance. This is already covered by test_wp_save_image_file(), which would fail if there is an unexpected deprecation notice.

Follow-up to [1061/tests], [25408], [25409], [53529].

See #56793.

Location:
trunk/tests/phpunit/tests
Files:
1 deleted
1 edited

Legend:

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

    r54226 r55066  
    326326
    327327        return $data;
     328    }
     329
     330    /**
     331     * Tests that wp_save_image_file() throws a deprecated argument notice when passed a GD resource.
     332     *
     333     * @ticket 6821
     334     * @expectedDeprecated wp_save_image_file
     335     * @requires function imagejpeg
     336     *
     337     * @covers ::wp_save_image_file
     338     */
     339    public function test_wp_save_image_file_deprecated_argument_with_gd_resource() {
     340        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
     341
     342        // Call wp_save_image_file().
     343        $file = wp_tempnam();
     344        $img  = imagecreatefromjpeg( DIR_TESTDATA . '/images/canola.jpg' );
     345        $ret  = wp_save_image_file( $file, $img, 'image/jpeg', 1 );
     346
     347        imagedestroy( $img );
     348        unlink( $file );
     349
     350        $this->assertTrue( $ret, 'Image failed to save.' );
    328351    }
    329352
Note: See TracChangeset for help on using the changeset viewer.