Make WordPress Core

Ticket #44605: 44605.diff

File 44605.diff, 4.3 KB (added by pbiron, 8 years ago)
  • tests/phpunit/tests/customize/manager.php

    From 5764d952e7a129f58b19b32a60ebc52bed9c90b8 Mon Sep 17 00:00:00 2001
    From: Paul Biron <paul@sparrowhawkcomputing.com>
    Date: Wed, 18 Jul 2018 16:16:59 -0600
    Subject: [PATCH] unit tests that create tmp files should use
     sys_get_temp_dir() instead of hardcoding /tmp/
    
    ---
     tests/phpunit/tests/customize/manager.php                    | 4 ++--
     tests/phpunit/tests/rest-api/rest-attachments-controller.php | 4 ++--
     tests/phpunit/tests/widgets/media-gallery-widget.php         | 2 +-
     tests/phpunit/tests/widgets/media-image-widget.php           | 2 +-
     tests/phpunit/tests/widgets/media-widget.php                 | 2 +-
     5 files changed, 7 insertions(+), 7 deletions(-)
    
    diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php
    index aad5d1f..4fff28b 100644
    a b class Tests_WP_Customize_Manager extends WP_UnitTestCase { 
    6060                $this->undefined = new stdClass();
    6161
    6262                $orig_file       = DIR_TESTDATA . '/images/canola.jpg';
    63                 $this->test_file = '/tmp/canola.jpg';
     63                $this->test_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg';
    6464                copy( $orig_file, $this->test_file );
    6565                $orig_file2       = DIR_TESTDATA . '/images/waffles.jpg';
    66                 $this->test_file2 = '/tmp/waffles.jpg';
     66                $this->test_file2 = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'waffles.jpg';
    6767                copy( $orig_file2, $this->test_file2 );
    6868        }
    6969
  • tests/phpunit/tests/rest-api/rest-attachments-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php
    index 2131e03..a73cd80 100644
    a b class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control 
    6868                $role->add_cap( 'level_0' );
    6969
    7070                $orig_file       = DIR_TESTDATA . '/images/canola.jpg';
    71                 $this->test_file = '/tmp/canola.jpg';
     71                $this->test_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg';
    7272                copy( $orig_file, $this->test_file );
    7373                $orig_file2       = DIR_TESTDATA . '/images/codeispoetry.png';
    74                 $this->test_file2 = '/tmp/codeispoetry.png';
     74                $this->test_file2 = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'codeispoetry.jpg';
    7575                copy( $orig_file2, $this->test_file2 );
    7676        }
    7777
  • tests/phpunit/tests/widgets/media-gallery-widget.php

    diff --git a/tests/phpunit/tests/widgets/media-gallery-widget.php b/tests/phpunit/tests/widgets/media-gallery-widget.php
    index 401a788..aa69612 100644
    a b class Test_WP_Widget_Media_Gallery extends WP_UnitTestCase { 
    5858
    5959                $attachments = array();
    6060                foreach ( array( 'canola.jpg', 'waffles.jpg' ) as $filename ) {
    61                         $test_image = '/tmp/' . $filename;
     61                        $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
    6262                        copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    6363                        $attachment_id = self::factory()->attachment->create_object(
    6464                                array(
  • tests/phpunit/tests/widgets/media-image-widget.php

    diff --git a/tests/phpunit/tests/widgets/media-image-widget.php b/tests/phpunit/tests/widgets/media-image-widget.php
    index d534e85..da16ff4 100644
    a b class Test_WP_Widget_Media_Image extends WP_UnitTestCase { 
    357357        function test_render_media() {
    358358                $widget = new WP_Widget_Media_Image();
    359359
    360                 $test_image = '/tmp/canola.jpg';
     360                $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg';
    361361                copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    362362                $attachment_id = self::factory()->attachment->create_object(
    363363                        array(
  • tests/phpunit/tests/widgets/media-widget.php

    diff --git a/tests/phpunit/tests/widgets/media-widget.php b/tests/phpunit/tests/widgets/media-widget.php
    index e165d86..622c62b 100644
    a b class Test_WP_Widget_Media extends WP_UnitTestCase { 
    137137         */
    138138        function test_is_attachment_with_mime_type() {
    139139
    140                 $test_image = '/tmp/canola.jpg';
     140                $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg';
    141141                copy( DIR_TESTDATA . '/images/canola.jpg', $test_image );
    142142                $attachment_id = self::factory()->attachment->create_object(
    143143                        array(