From e0187803271bb937d8bf27a4580a6a4758985bff Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Thu, 4 Aug 2011 22:33:04 +0000 Subject: [PATCH] Fixes for r92251: * Move Imagick check into getImageWriteMethod(), adjust exception catching. Previously this was bailing on the test if you have convert but not the PHP Imagick extension. Now all these tests are passing for me again. * Rm unused member variable, whitespace, etc --- tests/phpunit/includes/api/ApiUploadTest.php | 9 +++++---- .../phpunit/includes/api/RandomImageGenerator.php | 15 +++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/includes/api/ApiUploadTest.php b/tests/phpunit/includes/api/ApiUploadTest.php index 5c9297845a..1e22d20dee 100644 --- a/tests/phpunit/includes/api/ApiUploadTest.php +++ b/tests/phpunit/includes/api/ApiUploadTest.php @@ -107,12 +107,12 @@ class ApiUploadTest extends ApiTestCaseUpload { try { $randomImageGenerator = new RandomImageGenerator(); + $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); } catch ( Exception $e ) { $this->markTestIncomplete( $e->getMessage() ); } - $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); $filePath = $filePaths[0]; $fileSize = filesize( $filePath ); $fileName = basename( $filePath ); @@ -204,12 +204,12 @@ class ApiUploadTest extends ApiTestCaseUpload { try { $randomImageGenerator = new RandomImageGenerator(); + $filePaths = $randomImageGenerator->writeImages( 2, $extension, wfTempDir() ); } catch ( Exception $e ) { $this->markTestIncomplete( $e->getMessage() ); } - $filePaths = $randomImageGenerator->writeImages( 2, $extension, wfTempDir() ); // we'll reuse this filename $fileName = basename( $filePaths[0] ); @@ -278,11 +278,12 @@ class ApiUploadTest extends ApiTestCaseUpload { try { $randomImageGenerator = new RandomImageGenerator(); + $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); } catch ( Exception $e ) { $this->markTestIncomplete( $e->getMessage() ); } - $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); + $fileNames[0] = basename( $filePaths[0] ); $fileNames[1] = "SameContentAs" . $fileNames[0]; @@ -361,12 +362,12 @@ class ApiUploadTest extends ApiTestCaseUpload { try { $randomImageGenerator = new RandomImageGenerator(); + $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); } catch ( Exception $e ) { $this->markTestIncomplete( $e->getMessage() ); } - $filePaths = $randomImageGenerator->writeImages( 1, $extension, wfTempDir() ); $filePath = $filePaths[0]; $fileSize = filesize( $filePath ); $fileName = basename( $filePath ); diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index 69c017a3d8..a020f3dec1 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -91,14 +91,6 @@ class RandomImageGenerator { if ( !isset( $this->dictionaryFile ) ) { throw new Exception( "RandomImageGenerator: dictionary file not found or not specified properly" ); } - - if ( !class_exists( 'Imagick' ) ) { - throw new Exception( 'No Imagick extension' ); - } - global $wgExiv2Command; - if ( !$wgExiv2Command || !is_executable( $wgExiv2Command ) ) { - throw new Exception( 'exiv2 not executable or $wgExiv2Command not set' ); - } } /** @@ -129,7 +121,8 @@ class RandomImageGenerator { return 'writeSvg'; } else { // figure out how to write images - if ( class_exists( 'Imagick' ) ) { + global $wgExiv2Command; + if ( class_exists( 'Imagick' ) && $wgExiv2Command && is_executable( $wgExiv2Command ) ) { return 'writeImageWithApi'; } elseif ( $wgUseImageMagick && $wgImageMagickConvertCommand && is_executable( $wgImageMagickConvertCommand ) ) { return 'writeImageWithCommandLine'; @@ -304,9 +297,7 @@ class RandomImageGenerator { if ( $retval !== 0 ) { print "Error with $cmd: $retval, $err\n"; } - } - - + } } /** -- 2.20.1