Fixes for r92251:
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 4 Aug 2011 22:33:04 +0000 (22:33 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 4 Aug 2011 22:33:04 +0000 (22:33 +0000)
* 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
tests/phpunit/includes/api/RandomImageGenerator.php

index 5c92978..1e22d20 100644 (file)
@@ -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 );
index 69c017a..a020f3d 100644 (file)
@@ -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";
                        }
-                }
-
-
+               }
        }
 
        /**