Make WordPress Core

Ticket #39975: 39975.3.diff

File 39975.3.diff, 9.0 KB (added by christophherr, 6 years ago)

Removes symlinks from phpunit/tests/link/themeFile.php using parts of @danielhueskens patch on #40856

  • tests/phpunit/tests/file.php

     
    88        function setUp() {
    99                parent::setUp();
    1010
    11                 $file = tempnam( '/tmp', 'foo') ;
    12                 $this->dir = dirname( $file );
    13                 unlink( $file );
    14 
     11                $this->dir      = rtrim( get_temp_dir(), DIRECTORY_SEPARATOR );
    1512                $this->badchars = '"\'[]*&?$';
    1613        }
    1714
  • tests/phpunit/tests/image/functions.php

     
    2020                include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' );
    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 ) {
    2626                        unlink( $file );
     
    368368                }
    369369
    370370                $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf';
    371                 $test_file = '/tmp/wordpress-gsoc-flyer.pdf';
     371                $test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf';
    372372                copy( $orig_file, $test_file );
    373373
    374374                $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array(
     
    411411
    412412                unlink( $test_file );
    413413                foreach ( $metadata['sizes'] as $size ) {
    414                         unlink ( '/tmp/' . $size['file'] );
     414                        unlink ( get_temp_dir() . '' . $size['file'] );
    415415                }
    416416        }
    417417
     
    424424                }
    425425
    426426                $orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf';
    427                 $test_file = '/tmp/wordpress-gsoc-flyer.pdf';
     427                $test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf';
    428428                copy( $orig_file, $test_file );
    429429
    430430                $attachment_id = $this->factory->attachment->create_object( $test_file, 0, array(
     
    452452
    453453                unlink( $test_file );
    454454                foreach ( $metadata['sizes'] as $size ) {
    455                         unlink ( '/tmp/' . $size['file'] );
     455                        unlink ( get_temp_dir() . '' . $size['file'] );
    456456                }
    457457        }
    458458
     
    473473                }
    474474
    475475                // Dummy JPEGs.
    476                 $jpg1_path = '/tmp/test.jpg'; // Straight.
     476                $jpg1_path = get_temp_dir() . 'test.jpg'; // Straight.
    477477                file_put_contents( $jpg1_path, 'asdf' );
    478                 $jpg2_path = '/tmp/test-pdf.jpg'; // With PDF marker.
     478                $jpg2_path = get_temp_dir() . 'test-pdf.jpg'; // With PDF marker.
    479479                file_put_contents( $jpg2_path, 'fdsa' );
    480480
    481481                // PDF with same name as JPEG.
    482                 $pdf_path = '/tmp/test.pdf';
     482                $pdf_path = get_temp_dir() . 'test.pdf';
    483483                copy( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf', $pdf_path );
    484484
    485485                $attachment_id = $this->factory->attachment->create_object( $pdf_path, 0, array(
     
    487487                ) );
    488488
    489489                $metadata = wp_generate_attachment_metadata( $attachment_id, $pdf_path );
    490                 $preview_path = '/tmp/' . $metadata['sizes']['full']['file'];
     490                $preview_path = get_temp_dir() . '' . $metadata['sizes']['full']['file'];
    491491
    492492                // PDF preview didn't overwrite PDF.
    493493                $this->assertNotEquals( $pdf_path, $preview_path );
     
    503503                unlink( $jpg2_path );
    504504                unlink( $pdf_path );
    505505                foreach ( $metadata['sizes'] as $size ) {
    506                         unlink( '/tmp/' . $size['file'] );
     506                        unlink( get_temp_dir() . '' . $size['file'] );
    507507                }
    508508        }
    509509}
  • tests/phpunit/tests/link/themeFile.php

     
    55class Test_Theme_File extends WP_UnitTestCase {
    66
    77        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    8                 symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' );
    9                 symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' );
    10         }
     8                mkdir( WP_CONTENT_DIR . '/themes/theme-file-parent' );
     9                copy( DIR_TESTDATA . '/theme-file-parent/parent-and-child.php', WP_CONTENT_DIR . '/themes/theme-file-parent/parent-and-child.php' );
     10                copy( DIR_TESTDATA . '/theme-file-parent/parent-only.php', WP_CONTENT_DIR . '/themes/theme-file-parent/parent-only.php' );
     11                copy( DIR_TESTDATA . '/theme-file-parent/style.css', WP_CONTENT_DIR . '/themes/theme-file-parent/style.css' );
    1112
     13                mkdir( WP_CONTENT_DIR . '/themes/theme-file-child' );
     14                copy( DIR_TESTDATA . '/theme-file-child/parent-and-child.php', WP_CONTENT_DIR . '/themes/theme-file-child/parent-and-child.php' );
     15                copy( DIR_TESTDATA . '/theme-file-child/child-only.php', WP_CONTENT_DIR . '/themes/theme-file-child/child-only.php' );
     16                copy( DIR_TESTDATA . '/theme-file-child/style.css', WP_CONTENT_DIR . '/themes/theme-file-child/style.css' );}
     17
    1218        public static function wpTearDownAfterClass() {
    13                 unlink( WP_CONTENT_DIR . '/themes/theme-file-parent' );
    14                 unlink( WP_CONTENT_DIR . '/themes/theme-file-child' );
     19                unlink( WP_CONTENT_DIR . '/themes/theme-file-parent/parent-and-child.php' );
     20                unlink( WP_CONTENT_DIR . '/themes/theme-file-parent/parent-only.php' );
     21                unlink( WP_CONTENT_DIR . '/themes/theme-file-parent/style.css' );
     22                rmdir( WP_CONTENT_DIR . '/themes/theme-file-parent' );
     23                unlink( WP_CONTENT_DIR . '/themes/theme-file-child/parent-and-child.php' );
     24                unlink( WP_CONTENT_DIR . '/themes/theme-file-child/child-only.php' );
     25                unlink( WP_CONTENT_DIR . '/themes/theme-file-child/style.css' );
     26                rmdir( WP_CONTENT_DIR . '/themes/theme-file-child' );
    1527        }
    1628
    1729        /**
  • tests/phpunit/tests/rest-api/rest-attachments-controller.php

     
    5858                $role->add_cap( 'level_0' );
    5959
    6060                $orig_file = DIR_TESTDATA . '/images/canola.jpg';
    61                 $this->test_file = '/tmp/canola.jpg';
     61                $this->test_file = get_temp_dir() . 'canola.jpg';
    6262                copy( $orig_file, $this->test_file );
    6363                $orig_file2 = DIR_TESTDATA . '/images/codeispoetry.png';
    64                 $this->test_file2 = '/tmp/codeispoetry.png';
     64                $this->test_file2 = get_temp_dir() . 'codeispoetry.png';
    6565                copy( $orig_file2, $this->test_file2 );
    6666        }
    6767
  • tests/phpunit/tests/rest-api/rest-schema-setup.php

     
    176176                        'description' => 'REST API Client Fixture: Tag',
    177177                ) );
    178178
    179                 $media_id = $this->factory->attachment->create_object( '/tmp/canola.jpg', 0, array(
     179                $media_id = $this->factory->attachment->create_object( get_temp_dir() . 'canola.jpg', 0, array(
    180180                        'post_mime_type' => 'image/jpeg',
    181181                        'post_excerpt'   => 'A sample caption',
    182182                        'post_name'      => 'restapi-client-fixture-attachment',
  • tests/phpunit/tests/upload.php

     
    4646         * @ticket 5953
    4747         */
    4848        function test_upload_dir_absolute() {
    49                 $path = '/tmp/wp-unit-test';
     49                $path = get_temp_dir() . 'wp-unit-test';
    5050
    5151                // wp_upload_dir() with an absolute upload path
    5252                update_option( 'upload_path', $path );
  • tests/phpunit/tests/widgets/media-gallery-widget.php

     
    5858
    5959                $attachments = array();
    6060                foreach ( array( 'canola.jpg', 'waffles.jpg' ) as $filename ) {
    61                         $test_image = '/tmp/' . $filename;
     61                        $test_image = get_temp_dir() . $filename;
    6262                        copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    6363                        $attachment_id = self::factory()->attachment->create_object( array(
    6464                                'file' => $test_image,
  • tests/phpunit/tests/widgets/media-image-widget.php

     
    311311        function test_render_media() {
    312312                $widget = new WP_Widget_Media_Image();
    313313
    314                 $test_image = '/tmp/canola.jpg';
     314                $test_image = get_temp_dir() . 'canola.jpg';
    315315                copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    316316                $attachment_id = self::factory()->attachment->create_object( array(
    317317                        'file' => $test_image,
  • tests/phpunit/tests/widgets/media-widget.php

     
    129129         */
    130130        function test_is_attachment_with_mime_type() {
    131131
    132                 $test_image = '/tmp/canola.jpg';
     132                $test_image = get_temp_dir() . 'canola.jpg';
    133133                copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    134134                $attachment_id = self::factory()->attachment->create_object( array(
    135135                        'file' => $test_image,