aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/ImageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/ImageTest.php')
-rw-r--r--tests/lib/ImageTest.php94
1 files changed, 47 insertions, 47 deletions
diff --git a/tests/lib/ImageTest.php b/tests/lib/ImageTest.php
index 76b110df521..5de5435335a 100644
--- a/tests/lib/ImageTest.php
+++ b/tests/lib/ImageTest.php
@@ -14,27 +14,27 @@ use OCP\IConfig;
class ImageTest extends \Test\TestCase {
public static function tearDownAfterClass(): void {
- @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');
parent::tearDownAfterClass();
}
public function testConstructDestruct(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertInstanceOf('\OC\Image', $img);
$this->assertInstanceOf('\OCP\IImage', $img);
unset($img);
- $imgcreate = imagecreatefromjpeg(OC::$SERVERROOT.'/tests/data/testimage.jpg');
+ $imgcreate = imagecreatefromjpeg(OC::$SERVERROOT . '/tests/data/testimage.jpg');
$img = new Image();
$img->setResource($imgcreate);
$this->assertInstanceOf('\OC\Image', $img);
$this->assertInstanceOf('\OCP\IImage', $img);
unset($img);
- $base64 = base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
+ $base64 = base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif'));
$img = new Image();
$img->loadFromBase64($base64);
$this->assertInstanceOf('\OC\Image', $img);
@@ -49,7 +49,7 @@ class ImageTest extends \Test\TestCase {
public function testValid(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertTrue($img->valid());
$text = base64_encode('Lorem ipsum dolor sir amet …');
@@ -63,32 +63,32 @@ class ImageTest extends \Test\TestCase {
public function testMimeType(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertEquals('image/png', $img->mimeType());
$img = new Image();
$this->assertEquals('', $img->mimeType());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertEquals('image/jpeg', $img->mimeType());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertEquals('image/gif', $img->mimeType());
}
public function testWidth(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertEquals(128, $img->width());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertEquals(1680, $img->width());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertEquals(64, $img->width());
$img = new Image();
@@ -97,15 +97,15 @@ class ImageTest extends \Test\TestCase {
public function testHeight(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertEquals(128, $img->height());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertEquals(1050, $img->height());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertEquals(64, $img->height());
$img = new Image();
@@ -114,22 +114,22 @@ class ImageTest extends \Test\TestCase {
public function testSave(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$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->save(OC::$SERVERROOT . '/tests/data/testimage2.png');
+ $this->assertEquals(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage2.png'), $img->data());
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
+ $img->loadFromFile(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());
+ $img->save(OC::$SERVERROOT . '/tests/data/testimage2.jpg');
+ $this->assertEquals(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage2.jpg'), $img->data());
}
public function testData(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
- $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png'));
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
+ $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.png'));
// Preserve transparency
imagealphablending($raw, true);
imagesavealpha($raw, true);
@@ -149,8 +149,8 @@ class ImageTest extends \Test\TestCase {
->with('preview_max_memory', 256)
->willReturn(256);
$img = new Image(null, $appConfig, $config);
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.jpg');
- $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.jpg');
+ $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
imageinterlace($raw, true);
ob_start();
imagejpeg($raw, null, 80);
@@ -158,8 +158,8 @@ class ImageTest extends \Test\TestCase {
$this->assertEquals($expected, $img->data());
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.gif');
- $raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
+ $img->loadFromFile(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();
@@ -176,36 +176,36 @@ class ImageTest extends \Test\TestCase {
*/
public function testToString(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.gif');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.gif');
$expected = base64_encode($img->data());
$this->assertEquals($expected, (string)$img);
}
public function testResize(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertTrue($img->resize(32));
$this->assertEquals(32, $img->width());
$this->assertEquals(32, $img->height());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertTrue($img->resize(840));
$this->assertEquals(840, $img->width());
$this->assertEquals(525, $img->height());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertTrue($img->resize(100));
$this->assertEquals(100, $img->width());
$this->assertEquals(100, $img->height());
@@ -213,19 +213,19 @@ class ImageTest extends \Test\TestCase {
public function testPreciseResize(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertTrue($img->preciseResize(128, 512));
$this->assertEquals(128, $img->width());
$this->assertEquals(512, $img->height());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertTrue($img->preciseResize(64, 840));
$this->assertEquals(64, $img->width());
$this->assertEquals(840, $img->height());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertTrue($img->preciseResize(1000, 1337));
$this->assertEquals(1000, $img->width());
$this->assertEquals(1337, $img->height());
@@ -233,19 +233,19 @@ class ImageTest extends \Test\TestCase {
public function testCenterCrop(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$img->centerCrop();
$this->assertEquals(128, $img->width());
$this->assertEquals(128, $img->height());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$img->centerCrop();
$this->assertEquals(1050, $img->width());
$this->assertEquals(1050, $img->height());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$img->centerCrop(512);
$this->assertEquals(512, $img->width());
$this->assertEquals(512, $img->height());
@@ -253,19 +253,19 @@ class ImageTest extends \Test\TestCase {
public function testCrop(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$this->assertTrue($img->crop(0, 0, 50, 20));
$this->assertEquals(50, $img->width());
$this->assertEquals(20, $img->height());
$img = new Image();
- $img->loadFromData(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $img->loadFromData(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->assertTrue($img->crop(500, 700, 550, 300));
$this->assertEquals(550, $img->width());
$this->assertEquals(300, $img->height());
$img = new Image();
- $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif')));
+ $img->loadFromBase64(base64_encode(file_get_contents(OC::$SERVERROOT . '/tests/data/testimage.gif')));
$this->assertTrue($img->crop(10, 10, 15, 15));
$this->assertEquals(15, $img->width());
$this->assertEquals(15, $img->height());
@@ -311,7 +311,7 @@ class ImageTest extends \Test\TestCase {
*/
public function testScaleDownToFitWhenSmallerAlready($filename): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename);
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/' . $filename);
$currentWidth = $img->width();
$currentHeight = $img->height();
// We pick something larger than the image we want to scale down
@@ -344,7 +344,7 @@ class ImageTest extends \Test\TestCase {
*/
public function testScaleDownWhenBigger($filename, $asked, $expected): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename);
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/' . $filename);
//$this->assertTrue($img->scaleDownToFit($asked[0], $asked[1]));
$img->scaleDownToFit($asked[0], $asked[1]);
$this->assertEquals($expected[0], $img->width());
@@ -364,7 +364,7 @@ class ImageTest extends \Test\TestCase {
*/
public function testConvert($mimeType): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage.png');
$tempFile = tempnam(sys_get_temp_dir(), 'img-test');
$img->save($tempFile, $mimeType);
@@ -373,12 +373,12 @@ class ImageTest extends \Test\TestCase {
public function testMemoryLimitFromFile(): void {
$img = new Image();
- $img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage-badheader.jpg');
+ $img->loadFromFile(OC::$SERVERROOT . '/tests/data/testimage-badheader.jpg');
$this->assertFalse($img->valid());
}
public function testMemoryLimitFromData(): void {
- $data = file_get_contents(OC::$SERVERROOT.'/tests/data/testimage-badheader.jpg');
+ $data = file_get_contents(OC::$SERVERROOT . '/tests/data/testimage-badheader.jpg');
$img = new Image();
$img->loadFromData($data);
$this->assertFalse($img->valid());