Changeset 64260
- Timestamp:
- 10/09/2026 06:00:42 PM (4 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r64233 r64260 2157 2157 /** 2158 2158 * @ticket 65262 2159 * @requires function imagejpeg2160 2159 */ 2161 2160 public function test_image_quality_default_in_response() { 2162 2161 wp_set_current_user( self::$editor_id ); 2163 $attachment = self::factory()->attachment->create_upload_object( self::$test_file);2162 $attachment = $this->create_image_quality_test_attachment(); 2164 2163 2165 2164 $request = new WP_REST_Request( 'GET', "/wp/v2/media/{$attachment}" ); … … 2177 2176 /** 2178 2177 * @ticket 65262 2179 * @requires function imagejpeg2180 2178 */ 2181 2179 public function test_image_quality_with_size_aware_filter() { 2182 2180 wp_set_current_user( self::$editor_id ); 2183 $attachment = self::factory()->attachment->create_upload_object( self::$test_file);2181 $attachment = $this->create_image_quality_test_attachment(); 2184 2182 2185 2183 // Lower the quality for small images (e.g. thumbnails) only. … … 2213 2211 * 2214 2212 * @ticket 65262 2215 * @requires function imagejpeg2216 2213 */ 2217 2214 public function test_image_quality_honors_jpeg_quality_filter() { 2218 2215 wp_set_current_user( self::$editor_id ); 2219 $attachment = self::factory()->attachment->create_upload_object( self::$test_file);2216 $attachment = $this->create_image_quality_test_attachment(); 2220 2217 2221 2218 $filter = static function () { … … 2234 2231 // JPEG output, so the jpeg_quality filter overrides the 82 default. 2235 2232 $this->assertSame( 70, $data['image_quality']['default'] ); 2233 } 2234 2235 /** 2236 * Creates a JPEG attachment with static metadata for image quality tests. 2237 * 2238 * Quality reporting uses the MIME type, full-size dimensions, and registered 2239 * image sizes, so no upload or generated thumbnails are needed. 2240 * 2241 * @return int Attachment post ID. 2242 */ 2243 private function create_image_quality_test_attachment() { 2244 $attachment_id = self::factory()->attachment->create( 2245 array( 2246 'post_mime_type' => 'image/jpeg', 2247 'post_status' => 'inherit', 2248 'file' => 'canola.jpg', 2249 ) 2250 ); 2251 2252 wp_update_attachment_metadata( 2253 $attachment_id, 2254 array( 2255 'width' => 640, 2256 'height' => 480, 2257 'file' => 'canola.jpg', 2258 ) 2259 ); 2260 2261 return $attachment_id; 2236 2262 } 2237 2263
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)