Skip to content

Commit

Permalink
tests: add complex case
Browse files Browse the repository at this point in the history
  • Loading branch information
OxCom committed Jul 13, 2023
1 parent c60c6b4 commit 5cc69e8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/Providers/ImgProxy/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,42 @@ public function generateImageType()
[true, '2nfqtrOsPhesVatbaWIxzPZSNEFPaPILAH9MM2uwZh0', 'toWebP', 'webp'],
];
}

/**
* @dataProvider generateComplexBuildProcess
*/
public function testComplexBuildProcess(bool $secure, string $sign, string $toType, string $ext)
{
$host = 'conv.awesome.com';
$img = 'https://awesome.com/awesome/image.jpg';

$security = new Security('617765736F6D65', '6F78636F6D');
$builder = new Builder($security, 'conv.awesome.com');

$url = $builder
->url($img, $secure)
->gravity(ImgProxy::GRAVITY_NORTH_EAST, 3, 7)
->enlarge()
->extend(ImgProxy::GRAVITY_CENTER, 33, 42)
->crop(1024, 786)
->resize(768, 0, ImgProxy::RESIZE_TYPE_FORCE)
->zoom(0.33)
->{$toType}();

$options = 'g:noea:3:7/el:1/ex:1:ce:33:42/c:1024:786/rs:force:768:0/z:0.33';

self::assertEquals(
"https://{$host}/{$sign}/{$options}/plain/{$img}@{$ext}",
$url
);
}

public function generateComplexBuildProcess()
{
return [
[false, 'unsafe', 'toPng', 'png'],
[false, 'unsafe', 'toJpeg', 'jpg'],
[false, 'unsafe', 'toWebP', 'webp'],
];
}
}

0 comments on commit 5cc69e8

Please sign in to comment.