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 { |
| 60 | 60 | $this->undefined = new stdClass(); |
| 61 | 61 | |
| 62 | 62 | $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'; |
| 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 = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'waffles.jpg'; |
| 67 | 67 | copy( $orig_file2, $this->test_file2 ); |
| 68 | 68 | } |
| 69 | 69 | |
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 |
| 68 | 68 | $role->add_cap( 'level_0' ); |
| 69 | 69 | |
| 70 | 70 | $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'; |
| 72 | 72 | copy( $orig_file, $this->test_file ); |
| 73 | 73 | $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'; |
| 75 | 75 | copy( $orig_file2, $this->test_file2 ); |
| 76 | 76 | } |
| 77 | 77 | |
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 { |
| 58 | 58 | |
| 59 | 59 | $attachments = array(); |
| 60 | 60 | foreach ( array( 'canola.jpg', 'waffles.jpg' ) as $filename ) { |
| 61 | | $test_image = '/tmp/' . $filename; |
| | 61 | $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename; |
| 62 | 62 | copy( DIR_TESTDATA . '/images/canola.jpg', $test_image ); |
| 63 | 63 | $attachment_id = self::factory()->attachment->create_object( |
| 64 | 64 | array( |
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 { |
| 357 | 357 | function test_render_media() { |
| 358 | 358 | $widget = new WP_Widget_Media_Image(); |
| 359 | 359 | |
| 360 | | $test_image = '/tmp/canola.jpg'; |
| | 360 | $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg'; |
| 361 | 361 | copy( DIR_TESTDATA . '/images/canola.jpg', $test_image ); |
| 362 | 362 | $attachment_id = self::factory()->attachment->create_object( |
| 363 | 363 | array( |
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 { |
| 137 | 137 | */ |
| 138 | 138 | function test_is_attachment_with_mime_type() { |
| 139 | 139 | |
| 140 | | $test_image = '/tmp/canola.jpg'; |
| | 140 | $test_image = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'canola.jpg'; |
| 141 | 141 | copy( DIR_TESTDATA . '/images/canola.jpg', $test_image ); |
| 142 | 142 | $attachment_id = self::factory()->attachment->create_object( |
| 143 | 143 | array( |