|
|
@@ -57,16 +57,16 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @see ImageUtils::cropImage()
|
|
|
+ * @see ImageUtils::formatImage()
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testCropImageWithoutConfig()
|
|
|
+ public function testFormatImageWithoutConfig()
|
|
|
{
|
|
|
- $file = new File();
|
|
|
- $file->setPath('example.jpg');
|
|
|
- $file->setConfig(null);
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getPath')->willReturn('example.jpg');
|
|
|
+ $file->method('getConfig')->willReturn(null);
|
|
|
|
|
|
- $imageUtils = $this->getImageUtilsMockFor('cropImage');
|
|
|
+ $imageUtils = $this->getImageUtilsMockFor('formatImage');
|
|
|
|
|
|
$binary = $this->createMock(Binary::class);
|
|
|
$binary->method('getContent')->willReturn('mocked_binary_data');
|
|
|
@@ -76,20 +76,20 @@ class ImageUtilsTest extends TestCase
|
|
|
->with(ImageUtils::FILTER_CROP, $file->getPath())
|
|
|
->willReturn($binary);
|
|
|
|
|
|
- $result = $imageUtils->cropImage($file);
|
|
|
+ $result = $imageUtils->formatImage($file);
|
|
|
|
|
|
$this->assertEquals('mocked_binary_data', $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @see ImageUtils::cropImage()
|
|
|
+ * @see ImageUtils::formatImage()
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testCropImageWithConfig()
|
|
|
+ public function testFormatImageWithConfig()
|
|
|
{
|
|
|
- $file = new File();
|
|
|
- $file->setPath('example.jpg');
|
|
|
- $file->setConfig('{"width": 100, "height": 100, "x": 10, "y": 10}');
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getPath')->willReturn('example.jpg');
|
|
|
+ $file->method('getConfig')->willReturn('{"width": 100, "height": 100, "x": 10, "y": 10}');
|
|
|
$config = [
|
|
|
'filters' => [
|
|
|
'crop' => [
|
|
|
@@ -99,7 +99,7 @@ class ImageUtilsTest extends TestCase
|
|
|
]
|
|
|
];
|
|
|
|
|
|
- $imageUtils = $this->getImageUtilsMockFor('cropImage');
|
|
|
+ $imageUtils = $this->getImageUtilsMockFor('formatImage');
|
|
|
|
|
|
$binary = $this->createMock(Binary::class);
|
|
|
$binary->method('getContent')->willReturn('mocked_binary_data');
|
|
|
@@ -116,23 +116,23 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
$this->logger->expects($this->never())->method('error');
|
|
|
|
|
|
- $result = $imageUtils->cropImage($file);
|
|
|
+ $result = $imageUtils->formatImage($file);
|
|
|
|
|
|
$this->assertEquals('mocked_binary_data', $result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @see ImageUtils::cropImage()
|
|
|
+ * @see ImageUtils::formatImage()
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testCropImageWithErrorConfig()
|
|
|
+ public function testFormatImageWithErrorConfig()
|
|
|
{
|
|
|
- $file = new File();
|
|
|
- $file->setPath('example.jpg');
|
|
|
- $file->setConfig('{"hei": 100, "x": 10, "y": 10}');
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getPath')->willReturn('example.jpg');
|
|
|
+ $file->method('getConfig')->willReturn('{"hei": 100, "x": 10, "y": 10}');
|
|
|
|
|
|
- $imageUtils = $this->getImageUtilsMockFor('cropImage');
|
|
|
+ $imageUtils = $this->getImageUtilsMockFor('formatImage');
|
|
|
|
|
|
$binary = $this->createMock(Binary::class);
|
|
|
$binary->method('getContent')->willReturn('mocked_binary_data');
|
|
|
@@ -146,8 +146,36 @@ class ImageUtilsTest extends TestCase
|
|
|
->method('error')
|
|
|
;
|
|
|
|
|
|
- $result = $imageUtils->cropImage($file);
|
|
|
+ $result = $imageUtils->formatImage($file);
|
|
|
|
|
|
$this->assertEquals('mocked_binary_data', $result);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see ImageUtils::isImage()
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testIsImage()
|
|
|
+ {
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getMimeType')->willReturn('image/jpeg');
|
|
|
+
|
|
|
+ $imageUtils = $this->getImageUtilsMockFor('isImage');
|
|
|
+
|
|
|
+ $this->assertTrue($imageUtils->isImage($file));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @see ImageUtils::isImage()
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testIsNotImage()
|
|
|
+ {
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getMimeType')->willReturn('application/pdf');
|
|
|
+
|
|
|
+ $imageUtils = $this->getImageUtilsMockFor('isImage');
|
|
|
+
|
|
|
+ $this->assertFalse($imageUtils->isImage($file));
|
|
|
+ }
|
|
|
}
|