Make WordPress Core

Changeset 63777


Ignore:
Timestamp:
09/21/2026 05:46:35 PM (5 weeks ago)
Author:
lancewillett
Message:

Tests: Reduce image work in REST attachment tests.

Use attachment records without uploading images in three permission tests, and remove their unnecessary imagejpeg requirement. Skip intermediate image sizes in the EXIF orientation test while preserving the full-size image checks.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13619

Props sainathpoojary.
See #66074.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r63564 r63777  
    29742974        /**
    29752975         * @ticket 44405
    2976          * @requires function imagejpeg
    29772976         */
    29782977        public function test_edit_image_returns_error_if_logged_out() {
    2979                 $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
     2978                $attachment = self::factory()->attachment->create(
     2979                        array(
     2980                                'file'           => 'canola.jpg',
     2981                                'post_mime_type' => 'image/jpeg',
     2982                                'post_status'    => 'inherit',
     2983                        )
     2984                );
    29802985
    29812986                $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
    … …  
    29872992        /**
    29882993         * @ticket 44405
    2989          * @requires function imagejpeg
    29902994         */
    29912995        public function test_edit_image_returns_error_if_cannot_upload() {
    … …  
    29942998
    29952999                wp_set_current_user( $user->ID );
    2996                 $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
     3000                $attachment = self::factory()->attachment->create(
     3001                        array(
     3002                                'file'           => 'canola.jpg',
     3003                                'post_mime_type' => 'image/jpeg',
     3004                                'post_status'    => 'inherit',
     3005                        )
     3006                );
    29973007
    29983008                $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
    … …  
    30043014        /**
    30053015         * @ticket 44405
    3006          * @requires function imagejpeg
    30073016         */
    30083017        public function test_edit_image_returns_error_if_cannot_edit() {
    30093018                wp_set_current_user( self::$uploader_id );
    3010                 $attachment = self::factory()->attachment->create_upload_object( self::$test_file );
     3019                $attachment = self::factory()->attachment->create(
     3020                        array(
     3021                                'file'           => 'canola.jpg',
     3022                                'post_mime_type' => 'image/jpeg',
     3023                                'post_status'    => 'inherit',
     3024                        )
     3025                );
    30113026
    30123027                $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" );
    … …  
    32203235         */
    32213236        public function test_edit_image_rotate_with_unbaked_exif_orientation() {
     3237                // Only the full-size image dimensions are checked, so no intermediate sizes are needed.
     3238                add_filter( 'intermediate_image_sizes_advanced', '__return_empty_array' );
     3239
    32223240                wp_set_current_user( self::$superadmin_id );
    32233241                $attachment = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/test-image-rotated-90ccw.jpg' );
Note: See TracChangeset for help on using the changeset viewer.