Changeset 64036
- Timestamp:
- 10/01/2026 07:57:59 PM (7 weeks ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/image/functions.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/functions.php
r63880 r64036 380 380 require_once ABSPATH . 'wp-admin/includes/image-edit.php'; 381 381 382 $filename = DIR_TESTDATA . '/images/canola.jpg'; 383 $contents = file_get_contents( $filename ); 384 $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); 385 $id = $this->_make_attachment( $upload ); 382 $id = $this->create_image_editor_test_attachment(); 386 383 387 384 $filter = new MockAction(); … … 411 408 require_once ABSPATH . 'wp-admin/includes/image-edit.php'; 412 409 413 $filename = DIR_TESTDATA . '/images/canola.jpg'; 414 $contents = file_get_contents( $filename ); 415 $upload = wp_upload_bits( wp_basename( $filename ), null, $contents ); 416 $id = $this->_make_attachment( $upload ); 410 $id = $this->create_image_editor_test_attachment(); 417 411 418 412 add_filter( 'image_edit_thumbnails_separately', $callback ); … … 453 447 ), 454 448 ); 449 } 450 451 /** 452 * Creates a minimal image attachment for wp_image_editor() filter tests. 453 * 454 * Uses static metadata instead of generating real thumbnails. A thumbnail 455 * size entry is needed for the imgedit-applyto section to render. 456 * 457 * @return int Attachment post ID. 458 */ 459 private function create_image_editor_test_attachment() { 460 $attachment_id = self::factory()->attachment->create( 461 array( 462 'post_mime_type' => 'image/jpeg', 463 'file' => DIR_TESTDATA . '/images/canola.jpg', 464 ) 465 ); 466 467 wp_update_attachment_metadata( 468 $attachment_id, 469 array( 470 'width' => 640, 471 'height' => 480, 472 'file' => 'canola.jpg', 473 'sizes' => array( 474 'thumbnail' => array( 475 'file' => 'canola-150x150.jpg', 476 'width' => 150, 477 'height' => 150, 478 'mime-type' => 'image/jpeg', 479 ), 480 ), 481 ) 482 ); 483 484 return $attachment_id; 455 485 } 456 486
Note:
See TracChangeset
for help on using the changeset viewer.