WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/14/2020 01:28:17 AM (15 months ago)
Author:
SergeyBiryukov
Message:

Tests: Replace hardcoded /tmp/ references with get_temp_dir().

This allows more tests to pass on Windows.

Props danielhuesken, DJPaul, christophherr, joemcgill, netweb, davidbaumwald, SergeyBiryukov.
Fixes #40856, #39975.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/functions.php

    r48454 r48464  
    2121
    2222        // Ensure no legacy / failed tests detritus.
    23         $folder = '/tmp/wordpress-gsoc-flyer*.{jpg,pdf}';
     23        $folder = get_temp_dir() . 'wordpress-gsoc-flyer*.{jpg,pdf}';
    2424
    2525        foreach ( glob( $folder, GLOB_BRACE ) as $file ) {
     
    426426
    427427        $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';
    429429        copy( $orig_file, $test_file );
    430430
     
    477477
    478478        unlink( $test_file );
     479        $temp_dir = get_temp_dir();
    479480        foreach ( $metadata['sizes'] as $size ) {
    480             unlink( '/tmp/' . $size['file'] );
     481            unlink( $temp_dir . $size['file'] );
    481482        }
    482483    }
     
    561562
    562563        $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';
    564565        copy( $orig_file, $test_file );
    565566
     
    597598
    598599        unlink( $test_file );
     600        $temp_dir = get_temp_dir();
    599601        foreach ( $metadata['sizes'] as $size ) {
    600             unlink( '/tmp/' . $size['file'] );
     602            unlink( $temp_dir . $size['file'] );
    601603        }
    602604    }
     
    619621        }
    620622
     623        $temp_dir = get_temp_dir();
     624
    621625        // Dummy JPEGs.
    622         $jpg1_path = '/tmp/test.jpg'; // Straight.
     626        $jpg1_path = $temp_dir . 'test.jpg'; // Straight.
    623627        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.
    625629        file_put_contents( $jpg2_path, 'fdsa' );
    626630
    627631        // PDF with same name as JPEG.
    628         $pdf_path = '/tmp/test.pdf';
     632        $pdf_path = $temp_dir . 'test.pdf';
    629633        copy( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf', $pdf_path );
    630634
     
    643647
    644648        $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'];
    646650
    647651        // PDF preview didn't overwrite PDF.
     
    659663        unlink( $pdf_path );
    660664        foreach ( $metadata['sizes'] as $size ) {
    661             unlink( '/tmp/' . $size['file'] );
     665            unlink( $temp_dir . $size['file'] );
    662666        }
    663667    }
Note: See TracChangeset for help on using the changeset viewer.