|
@@ -3,7 +3,7 @@
|
|
|
namespace App\tests\Unit\Service\File\Utils;
|
|
namespace App\tests\Unit\Service\File\Utils;
|
|
|
|
|
|
|
|
use App\Entity\Core\File;
|
|
use App\Entity\Core\File;
|
|
|
-use App\Service\File\Utils\ImageUtils;
|
|
|
|
|
|
|
+use App\Service\File\Utils\FileUtils;
|
|
|
use App\Tests\Unit\TestToolsTrait;
|
|
use App\Tests\Unit\TestToolsTrait;
|
|
|
use Liip\ImagineBundle\Imagine\Data\DataManager;
|
|
use Liip\ImagineBundle\Imagine\Data\DataManager;
|
|
|
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
|
|
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
|
|
@@ -28,16 +28,16 @@ class ImageUtilsTest extends TestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getImageUtilsMockFor(string $methodName) {
|
|
public function getImageUtilsMockFor(string $methodName) {
|
|
|
- return $this->getMockBuilder(ImageUtils::class)
|
|
|
|
|
|
|
+ return $this->getMockBuilder(FileUtils::class)
|
|
|
->setConstructorArgs([$this->dataManager, $this->filterManager, $this->logger])
|
|
->setConstructorArgs([$this->dataManager, $this->filterManager, $this->logger])
|
|
|
->setMethodsExcept([$methodName])
|
|
->setMethodsExcept([$methodName])
|
|
|
->getMock();
|
|
->getMock();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::getCroppingConfig()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
* @throws \ReflectionException
|
|
* @throws \ReflectionException
|
|
|
|
|
+ *@see FileUtils::getCroppingConfig()
|
|
|
*/
|
|
*/
|
|
|
public function testGetCroppingConfig(): void {
|
|
public function testGetCroppingConfig(): void {
|
|
|
$imageUtils = $this->getImageUtilsMockFor('getCroppingConfig');
|
|
$imageUtils = $this->getImageUtilsMockFor('getCroppingConfig');
|
|
@@ -57,8 +57,8 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::formatImage()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
|
|
+ *@see FileUtils::formatImage()
|
|
|
*/
|
|
*/
|
|
|
public function testFormatImageWithoutConfig()
|
|
public function testFormatImageWithoutConfig()
|
|
|
{
|
|
{
|
|
@@ -73,7 +73,7 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
$this->dataManager->expects($this->once())
|
|
$this->dataManager->expects($this->once())
|
|
|
->method('find')
|
|
->method('find')
|
|
|
- ->with(ImageUtils::FILTER_CROP, $file->getPath())
|
|
|
|
|
|
|
+ ->with(FileUtils::FILTER_CROP, $file->getPath())
|
|
|
->willReturn($binary);
|
|
->willReturn($binary);
|
|
|
|
|
|
|
|
$result = $imageUtils->formatImage($file);
|
|
$result = $imageUtils->formatImage($file);
|
|
@@ -82,8 +82,8 @@ class ImageUtilsTest extends TestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::formatImage()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
|
|
+ *@see FileUtils::formatImage()
|
|
|
*/
|
|
*/
|
|
|
public function testFormatImageWithConfig()
|
|
public function testFormatImageWithConfig()
|
|
|
{
|
|
{
|
|
@@ -106,12 +106,12 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
$this->dataManager->expects($this->once())
|
|
$this->dataManager->expects($this->once())
|
|
|
->method('find')
|
|
->method('find')
|
|
|
- ->with(ImageUtils::FILTER_CROP, $file->getPath())
|
|
|
|
|
|
|
+ ->with(FileUtils::FILTER_CROP, $file->getPath())
|
|
|
->willReturn($binary);
|
|
->willReturn($binary);
|
|
|
|
|
|
|
|
$this->filterManager->expects($this->once())
|
|
$this->filterManager->expects($this->once())
|
|
|
->method('applyFilter')
|
|
->method('applyFilter')
|
|
|
- ->with($binary, ImageUtils::FILTER_CROP, $config)
|
|
|
|
|
|
|
+ ->with($binary, FileUtils::FILTER_CROP, $config)
|
|
|
->willReturn($binary);
|
|
->willReturn($binary);
|
|
|
|
|
|
|
|
$this->logger->expects($this->never())->method('error');
|
|
$this->logger->expects($this->never())->method('error');
|
|
@@ -123,8 +123,8 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::formatImage()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
|
|
+ *@see FileUtils::formatImage()
|
|
|
*/
|
|
*/
|
|
|
public function testFormatImageWithErrorConfig()
|
|
public function testFormatImageWithErrorConfig()
|
|
|
{
|
|
{
|
|
@@ -139,7 +139,7 @@ class ImageUtilsTest extends TestCase
|
|
|
|
|
|
|
|
$this->dataManager->expects($this->once())
|
|
$this->dataManager->expects($this->once())
|
|
|
->method('find')
|
|
->method('find')
|
|
|
- ->with(ImageUtils::FILTER_CROP, $file->getPath())
|
|
|
|
|
|
|
+ ->with(FileUtils::FILTER_CROP, $file->getPath())
|
|
|
->willReturn($binary);
|
|
->willReturn($binary);
|
|
|
|
|
|
|
|
$this->logger->expects($this->exactly(2))
|
|
$this->logger->expects($this->exactly(2))
|
|
@@ -152,8 +152,8 @@ class ImageUtilsTest extends TestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::isImage()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
|
|
+ *@see FileUtils::isImage()
|
|
|
*/
|
|
*/
|
|
|
public function testIsImage()
|
|
public function testIsImage()
|
|
|
{
|
|
{
|
|
@@ -166,8 +166,8 @@ class ImageUtilsTest extends TestCase
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * @see ImageUtils::isImage()
|
|
|
|
|
* @return void
|
|
* @return void
|
|
|
|
|
+ * @see FileUtils::isImage()
|
|
|
*/
|
|
*/
|
|
|
public function testIsNotImage()
|
|
public function testIsNotImage()
|
|
|
{
|
|
{
|