summaryrefslogtreecommitdiffstats
path: root/tests/lib/image.php
diff options
context:
space:
mode:
authorkondou <kondou@ts.unde.re>2013-08-06 16:56:50 +0200
committerkondou <kondou@ts.unde.re>2013-08-30 21:08:37 +0200
commit0869f9b655ddd0b285629256521d7eafde2f5d8a (patch)
tree4f62cd8e9f46d041912423ea91126e8f77fc922b /tests/lib/image.php
parent0f5df181a3b1f88075193fca0bed88f289314c8e (diff)
downloadnextcloud-server-0869f9b655ddd0b285629256521d7eafde2f5d8a.tar.gz
nextcloud-server-0869f9b655ddd0b285629256521d7eafde2f5d8a.zip
Fix #4258, clean up \OC_Image and improve its unittest
Diffstat (limited to 'tests/lib/image.php')
-rw-r--r--tests/lib/image.php33
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/lib/image.php b/tests/lib/image.php
index 0583c300075..b3db89cf5b8 100644
--- a/tests/lib/image.php
+++ b/tests/lib/image.php
@@ -7,6 +7,10 @@
*/
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');
+ }
public function testGetMimeTypeForFile() {
$mimetype = \OC_Image::getMimeTypeForFile(OC::$SERVERROOT.'/tests/data/testimage.png');
@@ -55,7 +59,6 @@ class Test_Image extends PHPUnit_Framework_TestCase {
}
public function testMimeType() {
- $this->markTestSkipped("When loading from data or base64, imagetype is always image/png, see #4258.");
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
$this->assertEquals('image/png', $img->mimeType());
@@ -102,35 +105,47 @@ class Test_Image extends PHPUnit_Framework_TestCase {
$img->resize(16);
$img->save(OC::$SERVERROOT.'/tests/data/testimage2.png');
$this->assertEquals(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage2.png'), $img->data());
+
+ $img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.jpg');
+ $img->resize(128);
+ $img->save(OC::$SERVERROOT.'/tests/data/testimage2.jpg');
+ $this->assertEquals(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage2.jpg'), $img->data());
}
public function testData() {
- $this->markTestSkipped("\OC_Image->data() converts to png before outputting data, see #4258.");
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
- $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png'));
+ ob_start();
+ imagepng($raw);
+ $expected = ob_get_clean();
$this->assertEquals($expected, $img->data());
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.jpg');
- $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg');
+ $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ ob_start();
+ imagejpeg($raw);
+ $expected = ob_get_clean();
$this->assertEquals($expected, $img->data());
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.gif');
- $expected = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif');
+ $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
+ ob_start();
+ imagegif($raw);
+ $expected = ob_get_clean();
$this->assertEquals($expected, $img->data());
}
public function testToString() {
- $this->markTestSkipped("\OC_Image->data() converts to png before outputting data, see #4258.");
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
- $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png'));
+ $expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
$img = new \OC_Image(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
- $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.gif');
- $expected = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
+ $expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
}