From 62bccb161973ce404d61965e575a4e839df4141a Mon Sep 17 00:00:00 2001
From: Sergey Biryukov <sergeybiryukov@git.wordpress.org>
Date: Tue, 14 Jul 2020 21:47:31 +0000
Subject: [PATCH] Tests: Temporarily skip PDF tests if they fail due to
 ImageMagick permission errors.

Merges [48338], [48341] to the 4.9 branch.

See #50573.

git-svn-id: https://develop.svn.wordpress.org/branches/4.9@48487 602fd350-edb4-49c9-b593-d223f7449a82
---
 tests/phpunit/tests/image/functions.php | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php
index b9fce73f4c..336b181327 100644
--- a/tests/phpunit/tests/image/functions.php
+++ b/tests/phpunit/tests/image/functions.php
@@ -371,6 +371,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
 		$test_file = '/tmp/wordpress-gsoc-flyer.pdf';
 		copy( $orig_file, $test_file );
 
+		$editor = wp_get_image_editor( $test_file );
+		if ( is_wp_error( $editor ) ) {
+			$this->markTestSkipped( $editor->get_error_message() );
+		}
+
 		$attachment_id = $this->factory->attachment->create_object( $test_file, 0, array(
 			'post_mime_type' => 'application/pdf',
 		) );
@@ -432,6 +437,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
 		$test_file = get_temp_dir() . 'wordpress-gsoc-flyer.pdf';
 		copy( $orig_file, $test_file );
 
+		$editor = wp_get_image_editor( $test_file );
+		if ( is_wp_error( $editor ) ) {
+			$this->markTestSkipped( $editor->get_error_message() );
+		}
+
 		$attachment_id = $this->factory->attachment->create_object(
 			$test_file, 0, array(
 				'post_mime_type' => 'application/pdf',
@@ -490,6 +500,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
 		$test_file = '/tmp/wordpress-gsoc-flyer.pdf';
 		copy( $orig_file, $test_file );
 
+		$editor = wp_get_image_editor( $test_file );
+		if ( is_wp_error( $editor ) ) {
+			$this->markTestSkipped( $editor->get_error_message() );
+		}
+
 		$attachment_id = $this->factory->attachment->create_object( $test_file, 0, array(
 			'post_mime_type' => 'application/pdf',
 		) );
@@ -545,6 +560,11 @@ class Tests_Image_Functions extends WP_UnitTestCase {
 		$pdf_path = '/tmp/test.pdf';
 		copy( DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf', $pdf_path );
 
+		$editor = wp_get_image_editor( $test_file );
+		if ( is_wp_error( $editor ) ) {
+			$this->markTestSkipped( $editor->get_error_message() );
+		}
+
 		$attachment_id = $this->factory->attachment->create_object( $pdf_path, 0, array(
 			'post_mime_type' => 'application/pdf',
 		) );