Skip to content

Commit

Permalink
test(image): resize on generate image
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Oct 7, 2023
1 parent 3d20c31 commit 5fcc715
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Storage/Processor/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

final class Config
class Config
{
/** @var array<string, mixed> */
private array $options;
Expand Down
34 changes: 34 additions & 0 deletions EMS/common-bundle/tests/Unit/Images/ImageProcessorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace EMS\CommonBundle\Tests\Unit\Images;

use EMS\CommonBundle\Storage\Processor\Config;
use EMS\CommonBundle\Storage\Processor\Image;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;

class ImageProcessorTest extends TestCase
{
public function testResizeImage(): void
{
$config = $this->createMock(Config::class);
$config->method('getConfigType')->willReturn('image');
$config->method('getWidth')->willReturn(2880);
$config->method('getHeight')->willReturn(1160);
$config->method('getQuality')->willReturn(0);
$config->method('getResize')->willReturn('fillArea');
$logger = $this->createMock(LoggerInterface::class);
$image = new Image($config, $logger);
$generatedImage = $image->generate(__DIR__.DIRECTORY_SEPARATOR.'visuel_giant.jpg');
\getimagesize($generatedImage);

$this->assertSame([
0 => 2880,
1 => 1160,
2 => 3,
3 => 'width="2880" height="1160"',
'bits' => 8,
'mime' => 'image/png',
], \getimagesize($generatedImage));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5fcc715

Please sign in to comment.