Changeset 48464
- Timestamp:
- 07/14/2020 01:28:17 AM (5 years ago)
- Location:
- trunk/tests/phpunit
- Files:
-
- 10 edited
-
includes/abstract-testcase.php (modified) (2 diffs)
-
tests/customize/manager.php (modified) (1 diff)
-
tests/file.php (modified) (1 diff)
-
tests/image/functions.php (modified) (8 diffs)
-
tests/rest-api/rest-attachments-controller.php (modified) (1 diff)
-
tests/rest-api/rest-schema-setup.php (modified) (1 diff)
-
tests/upload.php (modified) (1 diff)
-
tests/widgets/media-gallery-widget.php (modified) (1 diff)
-
tests/widgets/media-image-widget.php (modified) (1 diff)
-
tests/widgets/media-widget.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/abstract-testcase.php
r47880 r48464 914 914 $tmp_dir = ''; 915 915 $dirs = array( 'TMP', 'TMPDIR', 'TEMP' ); 916 916 917 foreach ( $dirs as $dir ) { 917 918 if ( isset( $_ENV[ $dir ] ) && ! empty( $_ENV[ $dir ] ) ) { … … 920 921 } 921 922 } 923 922 924 if ( empty( $tmp_dir ) ) { 923 $tmp_dir = '/tmp'; 924 } 925 $tmp_dir = get_temp_dir(); 926 } 927 925 928 $tmp_dir = realpath( $tmp_dir ); 929 926 930 return tempnam( $tmp_dir, 'wpunit' ); 927 931 } -
trunk/tests/phpunit/tests/customize/manager.php
r48438 r48464 61 61 62 62 $orig_file = DIR_TESTDATA . '/images/canola.jpg'; 63 $this->test_file = '/tmp/canola.jpg';63 $this->test_file = get_temp_dir() . 'canola.jpg'; 64 64 copy( $orig_file, $this->test_file ); 65 65 $orig_file2 = DIR_TESTDATA . '/images/waffles.jpg'; 66 $this->test_file2 = '/tmp/waffles.jpg';66 $this->test_file2 = get_temp_dir() . 'waffles.jpg'; 67 67 copy( $orig_file2, $this->test_file2 ); 68 68 } -
trunk/tests/phpunit/tests/file.php
r47122 r48464 9 9 parent::setUp(); 10 10 11 $file = tempnam( '/tmp', 'foo' ); 12 $this->dir = dirname( $file ); 13 unlink( $file ); 11 $this->dir = untrailingslashit( get_temp_dir() ); 14 12 15 13 $this->badchars = '"\'[]*&?$'; -
trunk/tests/phpunit/tests/image/functions.php
r48454 r48464 21 21 22 22 // Ensure no legacy / failed tests detritus. 23 $folder = '/tmp/wordpress-gsoc-flyer*.{jpg,pdf}';23 $folder = get_temp_dir() . 'wordpress-gsoc-flyer*.{jpg,pdf}'; 24 24 25 25 foreach ( glob( $folder, GLOB_BRACE ) as $file ) { … … 426 426 427 427 $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf'; 428 $test_file = '/tmp/wordpress-gsoc-flyer.pdf';428 $test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf'; 429 429 copy( $orig_file, $test_file ); 430 430 … … 477 477 478 478 unlink( $test_file ); 479 $temp_dir = get_temp_dir(); 479 480 foreach ( $metadata['sizes'] as $size ) { 480 unlink( '/tmp/'. $size['file'] );481 unlink( $temp_dir . $size['file'] ); 481 482 } 482 483 } … … 561 562 562 563 $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf'; 563 $test_file = '/tmp/wordpress-gsoc-flyer.pdf';564 $test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf'; 564 565 copy( $orig_file, $test_file ); 565 566 … … 597 598 598 599 unlink( $test_file ); 600 $temp_dir = get_temp_dir(); 599 601 foreach ( $metadata['sizes'] as $size ) { 600 unlink( '/tmp/'. $size['file'] );602 unlink( $temp_dir . $size['file'] ); 601 603 } 602 604 } … … 619 621 } 620 622 623 $temp_dir = get_temp_dir(); 624 621 625 // Dummy JPEGs. 622 $jpg1_path = '/tmp/test.jpg'; // Straight.626 $jpg1_path = $temp_dir . 'test.jpg'; // Straight. 623 627 file_put_contents( $jpg1_path, 'asdf' ); 624 $jpg2_path = '/tmp/test-pdf.jpg'; // With PDF marker.628 $jpg2_path = $temp_dir . 'test-pdf.jpg'; // With PDF marker. 625 629 file_put_contents( $jpg2_path, 'fdsa' ); 626 630 627 631 // PDF with same name as JPEG. 628 $pdf_path = '/tmp/test.pdf';632 $pdf_path = $temp_dir . 'test.pdf'; 629 633 copy( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf', $pdf_path ); 630 634 … … 643 647 644 648 $metadata = wp_generate_attachment_metadata( $attachment_id, $pdf_path ); 645 $preview_path = '/tmp/'. $metadata['sizes']['full']['file'];649 $preview_path = $temp_dir . $metadata['sizes']['full']['file']; 646 650 647 651 // PDF preview didn't overwrite PDF. … … 659 663 unlink( $pdf_path ); 660 664 foreach ( $metadata['sizes'] as $size ) { 661 unlink( '/tmp/'. $size['file'] );665 unlink( $temp_dir . $size['file'] ); 662 666 } 663 667