Changeset 52837 for trunk/tests/phpunit/tests/image/functions.php
- Timestamp:
- 03/10/2022 01:08:19 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/functions.php
r52269 r52837 480 480 $this->assertNotEmpty( $attachment_id ); 481 481 482 $temp_dir = get_temp_dir(); 483 484 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 485 482 486 $expected = array( 483 'sizes' => array(487 'sizes' => array( 484 488 'full' => array( 485 489 'file' => 'wordpress-gsoc-flyer-pdf.jpg', … … 487 491 'height' => 1408, 488 492 'mime-type' => 'image/jpeg', 493 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf.jpg' ), 489 494 ), 490 495 'medium' => array( … … 493 498 'height' => 300, 494 499 'mime-type' => 'image/jpeg', 500 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-232x300.jpg' ), 495 501 ), 496 502 'large' => array( … … 499 505 'height' => 1024, 500 506 'mime-type' => 'image/jpeg', 507 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-791x1024.jpg' ), 501 508 ), 502 509 'thumbnail' => array( … … 505 512 'height' => 150, 506 513 'mime-type' => 'image/jpeg', 514 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-116x150.jpg' ), 507 515 ), 508 516 ), 509 );510 511 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 517 'filesize' => wp_filesize( $test_file ), 518 ); 519 512 520 $this->assertSame( $expected, $metadata ); 513 521 514 522 unlink( $test_file ); 515 $temp_dir = get_temp_dir();516 523 foreach ( $metadata['sizes'] as $size ) { 517 524 unlink( $temp_dir . $size['file'] ); … … 550 557 $this->assertNotEmpty( $attachment_id ); 551 558 559 $temp_dir = get_temp_dir(); 560 561 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 562 552 563 $expected = array( 553 'sizes' => array(564 'sizes' => array( 554 565 'full' => array( 555 566 'file' => 'wordpress-gsoc-flyer-pdf.jpg', … … 557 568 'height' => 1408, 558 569 'mime-type' => 'image/jpeg', 570 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf.jpg' ), 559 571 ), 560 572 'medium' => array( … … 563 575 'height' => 300, 564 576 'mime-type' => 'image/jpeg', 577 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-300x300.jpg' ), 565 578 ), 566 579 'large' => array( … … 569 582 'height' => 1024, 570 583 'mime-type' => 'image/jpeg', 584 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-791x1024.jpg' ), 571 585 ), 572 586 'thumbnail' => array( … … 575 589 'height' => 150, 576 590 'mime-type' => 'image/jpeg', 591 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-116x150.jpg' ), 577 592 ), 578 593 ), 579 );580 581 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 594 'filesize' => wp_filesize( $test_file ), 595 ); 596 582 597 $this->assertSame( $expected, $metadata ); 583 598 584 599 unlink( $test_file ); 585 600 foreach ( $metadata['sizes'] as $size ) { 586 unlink( get_temp_dir(). $size['file'] );601 unlink( $temp_dir . $size['file'] ); 587 602 } 588 603 } … … 617 632 add_image_size( 'test-size', 100, 100 ); 618 633 add_filter( 'fallback_intermediate_image_sizes', array( $this, 'filter_fallback_intermediate_image_sizes' ), 10, 2 ); 634 635 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 636 637 $temp_dir = get_temp_dir(); 619 638 620 639 $expected = array( … … 623 642 'height' => 100, 624 643 'mime-type' => 'image/jpeg', 625 ); 626 627 $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file ); 644 'filesize' => wp_filesize( $temp_dir . 'wordpress-gsoc-flyer-pdf-77x100.jpg' ), 645 ); 646 647 // Different environments produce slightly different filesize results. 648 $this->assertSame( $metadata['sizes']['test-size'], $expected ); 649 628 650 $this->assertArrayHasKey( 'test-size', $metadata['sizes'], 'The `test-size` was not added to the metadata.' ); 629 651 $this->assertSame( $expected, $metadata['sizes']['test-size'] ); … … 633 655 634 656 unlink( $test_file ); 635 $temp_dir = get_temp_dir();636 657 foreach ( $metadata['sizes'] as $size ) { 637 658 unlink( $temp_dir . $size['file'] );
Note: See TracChangeset
for help on using the changeset viewer.