}
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);
}
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());
}
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());
}
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());
}
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());
}
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);
}
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'));
}
public function testDataNoResource() {
- if (PHP_MAJOR_VERSION > 7) {
- $this->markTestSkipped('Only run on php7');
- }
-
$img = new \OC_Image();
$this->assertNull($img->data());
}
* @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());
}
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));
}
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));
}
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();
}
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));
* @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]));
* @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();
* @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]));
* @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');