|
|
|
|
@ -20,10 +20,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testConstructDestruct() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertInstanceOf('\OC_Image', $img); |
|
|
|
|
@ -51,10 +47,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testValid() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertTrue($img->valid()); |
|
|
|
|
@ -69,10 +61,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testMimeType() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertEquals('image/png', $img->mimeType()); |
|
|
|
|
@ -90,10 +78,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testWidth() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertEquals(128, $img->width()); |
|
|
|
|
@ -111,10 +95,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testHeight() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertEquals(128, $img->height()); |
|
|
|
|
@ -132,10 +112,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testSave() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$img->resize(16); |
|
|
|
|
@ -150,10 +126,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testData() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$raw = imagecreatefromstring(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.png')); |
|
|
|
|
@ -188,10 +160,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDataNoResource() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$this->assertNull($img->data()); |
|
|
|
|
} |
|
|
|
|
@ -200,10 +168,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
* @depends testData |
|
|
|
|
*/ |
|
|
|
|
public function testToString() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$expected = base64_encode($img->data()); |
|
|
|
|
@ -221,10 +185,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testResize() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertTrue($img->resize(32)); |
|
|
|
|
@ -245,10 +205,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testPreciseResize() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertTrue($img->preciseResize(128, 512)); |
|
|
|
|
@ -269,10 +225,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testCenterCrop() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$img->centerCrop(); |
|
|
|
|
@ -293,10 +245,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testCrop() { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$this->assertTrue($img->crop(0, 0, 50, 20)); |
|
|
|
|
@ -332,10 +280,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
* @param int[] $expected |
|
|
|
|
*/ |
|
|
|
|
public function testFitIn($filename, $asked, $expected) { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT . '/tests/data/' . $filename); |
|
|
|
|
$this->assertTrue($img->fitIn($asked[0], $asked[1])); |
|
|
|
|
@ -359,10 +303,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
* @param string $filename |
|
|
|
|
*/ |
|
|
|
|
public function testScaleDownToFitWhenSmallerAlready($filename) { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename); |
|
|
|
|
$currentWidth = $img->width(); |
|
|
|
|
@ -396,10 +336,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
* @param int[] $expected |
|
|
|
|
*/ |
|
|
|
|
public function testScaleDownWhenBigger($filename, $asked, $expected) { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/' . $filename); |
|
|
|
|
//$this->assertTrue($img->scaleDownToFit($asked[0], $asked[1])); |
|
|
|
|
@ -420,10 +356,6 @@ class ImageTest extends \Test\TestCase { |
|
|
|
|
* @dataProvider convertDataProvider |
|
|
|
|
*/ |
|
|
|
|
public function testConvert($mimeType) { |
|
|
|
|
if (PHP_MAJOR_VERSION > 7) { |
|
|
|
|
$this->markTestSkipped('Only run on php7'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$img = new \OC_Image(); |
|
|
|
|
$img->loadFromFile(OC::$SERVERROOT.'/tests/data/testimage.png'); |
|
|
|
|
$tempFile = tempnam(sys_get_temp_dir(), 'img-test'); |
|
|
|
|
|