From d13de85c7b06e4743882ffd4125746d59b0bd2b3 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 12 Mar 2021 09:44:22 +0000 Subject: [PATCH 1/2] Use absolute file paths instead of relative #8473 --- tests/tests-query-filters.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests-query-filters.php b/tests/tests-query-filters.php index 59374db1ab0..0b231cbcf1d 100644 --- a/tests/tests-query-filters.php +++ b/tests/tests-query-filters.php @@ -37,7 +37,7 @@ public function test_edd_block_attachments_no_attachment_bail() { public function test_edd_block_attachments_no_parent_bail() { // Prepare test - $filename = '../assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -78,7 +78,7 @@ public function test_edd_block_attachments_no_download_bail() { 'post_status' => 'publish' ) ); - $filename = '../assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -140,7 +140,7 @@ public function test_edd_block_attachments_not_restricted_bail() { update_post_meta( $parent_post_id, $key, $value ); } - $filename = '../assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -202,7 +202,7 @@ public function test_edd_block_attachments_die() { update_post_meta( $parent_post_id, $key, $value ); } - $filename = '../assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); From c57fcf0c218979bcc4fc5466bbad0dbe63265e71 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Tue, 16 Mar 2021 13:02:16 +0000 Subject: [PATCH 2/2] Remove / from start & use basename when inserting attachment #8473 --- tests/tests-query-filters.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/tests-query-filters.php b/tests/tests-query-filters.php index 0b231cbcf1d..cf7fa3ab00b 100644 --- a/tests/tests-query-filters.php +++ b/tests/tests-query-filters.php @@ -37,7 +37,7 @@ public function test_edd_block_attachments_no_attachment_bail() { public function test_edd_block_attachments_no_parent_bail() { // Prepare test - $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . 'assets/images/loading.gif'; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -48,7 +48,7 @@ public function test_edd_block_attachments_no_parent_bail() { 'post_content' => '', 'post_status' => 'inherit' ); - $attach_id = wp_insert_attachment( $attachment, $filename, 0 ); + $attach_id = wp_insert_attachment( $attachment, basename( $filename ), 0 ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); @@ -78,7 +78,7 @@ public function test_edd_block_attachments_no_download_bail() { 'post_status' => 'publish' ) ); - $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . 'assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -90,7 +90,7 @@ public function test_edd_block_attachments_no_download_bail() { 'post_content' => '', 'post_status' => 'inherit' ); - $attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id ); + $attach_id = wp_insert_attachment( $attachment, basename( $filename ), $parent_post_id ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); @@ -140,7 +140,7 @@ public function test_edd_block_attachments_not_restricted_bail() { update_post_meta( $parent_post_id, $key, $value ); } - $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . 'assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -202,7 +202,7 @@ public function test_edd_block_attachments_die() { update_post_meta( $parent_post_id, $key, $value ); } - $filename = EDD_PLUGIN_DIR . '/assets/images/loading.gif'; + $filename = EDD_PLUGIN_DIR . 'assets/images/loading.gif'; $parent_post_id = $parent_post_id; $filetype = wp_check_filetype( basename( $filename ), null ); $wp_upload_dir = wp_upload_dir(); @@ -214,7 +214,7 @@ public function test_edd_block_attachments_die() { 'post_content' => '', 'post_status' => 'inherit' ); - $attach_id = wp_insert_attachment( $attachment, $filename, $parent_post_id ); + $attach_id = wp_insert_attachment( $attachment, basename( $filename ), $parent_post_id ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data );