[Pkg-owncloud-commits] [owncloud] 09/50: unit tests for specific image type output added

David Prévot taffit at moszumanska.debian.org
Fri Oct 17 03:12:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v6.0.6RC1
in repository owncloud.

commit f3d335b7c1ece35cfbd2dd1d866eb7699cb63514
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Mon Mar 17 08:40:59 2014 +0100

    unit tests for specific image type output added
---
 lib/private/image.php |  7 ++++++-
 tests/lib/image.php   | 24 ++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/lib/private/image.php b/lib/private/image.php
index 17648ba..4b4dc73 100644
--- a/lib/private/image.php
+++ b/lib/private/image.php
@@ -236,7 +236,12 @@ class OC_Image {
 				$retVal = imagepng($this->resource, $filePath);
 				break;
 			case IMAGETYPE_XBM:
-				$retVal = imagexbm($this->resource, $filePath);
+				if (function_exists('imagexbm')) {
+					$retVal = imagexbm($this->resource, $filePath);
+				} else {
+					throw new Exception('\OC_Image::_output(): imagexbm() is not supported.');
+				}
+
 				break;
 			case IMAGETYPE_WBMP:
 				$retVal = imagewbmp($this->resource, $filePath);
diff --git a/tests/lib/image.php b/tests/lib/image.php
index 4aba1b0..131a9d8 100644
--- a/tests/lib/image.php
+++ b/tests/lib/image.php
@@ -8,8 +8,8 @@
 
 class Test_Image extends PHPUnit_Framework_TestCase {
 	public static function tearDownAfterClass() {
-		unlink(OC::$SERVERROOT.'/tests/data/testimage2.png');
-		unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
+		@unlink(OC::$SERVERROOT.'/tests/data/testimage2.png');
+		@unlink(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
 	}
 
 	public function testGetMimeTypeForFile() {
@@ -236,4 +236,24 @@ class Test_Image extends PHPUnit_Framework_TestCase {
 		$this->assertEquals(200, $img->width());
 		$this->assertEquals(200, $img->height());
 	}
+
+	function convertDataProvider() {
+		return array(
+			array( 'image/gif'),
+			array( 'image/jpeg'),
+			array( 'image/png'),
+		);
+	}
+
+	/**
+	 * @dataProvider convertDataProvider
+	 */
+	public function testConvert($mimeType) {
+		$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
+		$tempFile = tempnam(sys_get_temp_dir(), 'img-test');
+
+		$img->save($tempFile, $mimeType);
+		$actualMimeType = \OC_Image::getMimeTypeForFile($tempFile);
+		$this->assertEquals($mimeType, $actualMimeType);
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list