mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 00:29:55 +02:00
exif() and orientate() now throw exception, if image is not instantiated from filepath
This commit is contained in:
@@ -21,6 +21,12 @@ class ExifCommand extends AbstractCommand
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! $image->basePath()) {
|
||||||
|
throw new \Intervention\Image\Exception\RuntimeException(
|
||||||
|
"Reading Exif data is only possible, if the image is instantiated from a filepath."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$key = $this->argument(0)->value();
|
$key = $this->argument(0)->value();
|
||||||
|
|
||||||
// try to read exif data from image file
|
// try to read exif data from image file
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Intervention\Image\Image;
|
||||||
use Intervention\Image\Commands\ExifCommand;
|
use Intervention\Image\Commands\ExifCommand;
|
||||||
|
|
||||||
class ExifCommandTest extends PHPUnit_Framework_TestCase
|
class ExifCommandTest extends PHPUnit_Framework_TestCase
|
||||||
@@ -11,7 +12,7 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFetchAll()
|
public function testFetchAll()
|
||||||
{
|
{
|
||||||
$image = Mockery::mock('Intervention\Image\Image');
|
$image = new Image;
|
||||||
$image->dirname = __DIR__.'/images';
|
$image->dirname = __DIR__.'/images';
|
||||||
$image->basename = 'exif.jpg';
|
$image->basename = 'exif.jpg';
|
||||||
$command = new ExifCommand(array());
|
$command = new ExifCommand(array());
|
||||||
@@ -23,7 +24,7 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFetchDefined()
|
public function testFetchDefined()
|
||||||
{
|
{
|
||||||
$image = Mockery::mock('Intervention\Image\Image');
|
$image = new Image;
|
||||||
$image->dirname = __DIR__.'/images';
|
$image->dirname = __DIR__.'/images';
|
||||||
$image->basename = 'exif.jpg';
|
$image->basename = 'exif.jpg';
|
||||||
$command = new ExifCommand(array('Artist'));
|
$command = new ExifCommand(array('Artist'));
|
||||||
@@ -35,7 +36,7 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFetchNonExisting()
|
public function testFetchNonExisting()
|
||||||
{
|
{
|
||||||
$image = Mockery::mock('Intervention\Image\Image');
|
$image = new Image;
|
||||||
$image->dirname = __DIR__.'/images';
|
$image->dirname = __DIR__.'/images';
|
||||||
$image->basename = 'exif.jpg';
|
$image->basename = 'exif.jpg';
|
||||||
$command = new ExifCommand(array('xxx'));
|
$command = new ExifCommand(array('xxx'));
|
||||||
@@ -47,7 +48,7 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testFetchFromPng()
|
public function testFetchFromPng()
|
||||||
{
|
{
|
||||||
$image = Mockery::mock('Intervention\Image\Image');
|
$image = new Image;
|
||||||
$image->dirname = __DIR__.'/images';
|
$image->dirname = __DIR__.'/images';
|
||||||
$image->basename = 'star.png';
|
$image->basename = 'star.png';
|
||||||
$command = new ExifCommand(array('Orientation'));
|
$command = new ExifCommand(array('Orientation'));
|
||||||
@@ -57,13 +58,13 @@ class ExifCommandTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(null, $command->getOutput());
|
$this->assertEquals(null, $command->getOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReturnNullOnExifReadFail()
|
/**
|
||||||
|
* @expectedException \Intervention\Image\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testFetchFromNonFileInstance()
|
||||||
{
|
{
|
||||||
$image = Mockery::mock('Intervention\Image\Image');
|
$image = new Image;
|
||||||
$command = new ExifCommand(array('Orientation'));
|
$command = new ExifCommand(array('Artist'));
|
||||||
$result = $command->execute($image);
|
$command->execute($image);
|
||||||
$this->assertTrue($result);
|
|
||||||
$this->assertTrue($command->hasOutput());
|
|
||||||
$this->assertEquals(null, $command->getOutput());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1497,6 +1497,15 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(null, $data);
|
$this->assertEquals(null, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Intervention\Image\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testExifReadNonFileInstance()
|
||||||
|
{
|
||||||
|
$img = $this->manager()->canvas(300, 200);
|
||||||
|
$data = $img->exif();
|
||||||
|
}
|
||||||
|
|
||||||
public function testSaveImage()
|
public function testSaveImage()
|
||||||
{
|
{
|
||||||
$save_as = 'tests/tmp/foo.jpg';
|
$save_as = 'tests/tmp/foo.jpg';
|
||||||
|
@@ -1483,6 +1483,15 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(null, $data);
|
$this->assertEquals(null, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Intervention\Image\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testExifReadNonFileInstance()
|
||||||
|
{
|
||||||
|
$img = $this->manager()->canvas(300, 200);
|
||||||
|
$data = $img->exif();
|
||||||
|
}
|
||||||
|
|
||||||
public function testSaveImage()
|
public function testSaveImage()
|
||||||
{
|
{
|
||||||
$save_as = 'tests/tmp/foo.jpg';
|
$save_as = 'tests/tmp/foo.jpg';
|
||||||
|
Reference in New Issue
Block a user