Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Jul 22, 2023
2 parents 61fb7d5 + 3d90a22 commit b5e897e
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 26 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ jobs:
dependencies: lowest
allowed-to-fail: false
variant: normal
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
variant: sonata-project/form-extensions:"2.0.0-alpha-1"
- php-version: '8.2'
dependencies: highest
allowed-to-fail: false
Expand Down
1 change: 0 additions & 1 deletion src/Block/FeatureMediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
}

$template = $blockContext->getTemplate();
\assert(\is_string($template));

return $this->renderResponse($template, [
'media' => $blockContext->getSetting('mediaId'),
Expand Down
1 change: 0 additions & 1 deletion src/Block/GalleryBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
{
$gallery = $blockContext->getBlock()->getSetting('galleryId');
$template = $blockContext->getTemplate();
\assert(\is_string($template));

return $this->renderResponse($template, [
'gallery' => $gallery,
Expand Down
1 change: 0 additions & 1 deletion src/Block/GalleryListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
$sortDirection = $blockContext->getSetting('sort');
\assert(\in_array($sortDirection, ['asc', 'desc'], true));
$template = $blockContext->getTemplate();
\assert(\is_string($template));

return $this->renderResponse($template, [
'context' => $blockContext,
Expand Down
1 change: 0 additions & 1 deletion src/Block/MediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response
}

$template = $blockContext->getTemplate();
\assert(\is_string($template));

return $this->renderResponse($template, [
'media' => $blockContext->getSetting('mediaId'),
Expand Down
4 changes: 2 additions & 2 deletions src/Resizer/SimpleResizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public function getBox(MediaInterface $media, array $settings): Box
}

if (null === $height) {
$height = (int) round($width * $size->getHeight() / $size->getWidth());
$height = max((int) round($width * $size->getHeight() / $size->getWidth()), 1);
}

if (null === $width) {
$width = (int) round($height * $size->getWidth() / $size->getHeight());
$width = max((int) round($height * $size->getWidth() / $size->getHeight()), 1);
}

return $this->computeBox($media, $width, $height);
Expand Down
3 changes: 0 additions & 3 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ protected function configureRoutes(RoutingConfigurator $routes): void
$routes->import(__DIR__.'/config/routes.yaml');
}

/**
* @psalm-suppress DeprecatedClass
*/
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/config.yaml');
Expand Down
3 changes: 0 additions & 3 deletions tests/Block/FeatureMediaBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ protected function setUp(): void
);
}

/**
* @psalm-suppress DeprecatedClass
*/
public function testDefaultSettings(): void
{
$blockContext = $this->getBlockContext($this->blockService);
Expand Down
3 changes: 0 additions & 3 deletions tests/Block/GalleryBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public function testExecute(): void
$this->blockService->execute($blockContext);
}

/**
* @psalm-suppress DeprecatedClass
*/
public function testDefaultSettings(): void
{
$blockContext = $this->getBlockContext($this->blockService);
Expand Down
3 changes: 0 additions & 3 deletions tests/Block/MediaBlockServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public function testExecute(): void
$this->blockService->execute($blockContext);
}

/**
* @psalm-suppress DeprecatedClass
*/
public function testDefaultSettings(): void
{
$blockContext = $this->getBlockContext($this->blockService);
Expand Down
8 changes: 4 additions & 4 deletions tests/Provider/FileProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,21 @@ public function testMetadata(): void
}

/**
* @psalm-suppress TooFewArguments, InvalidArgument
* @psalm-suppress TooManyArguments, InvalidArgument
*/
private function createErrorElement(ExecutionContextInterface $executionContext): ErrorElement
{
// TODO: Remove if when dropping support for `sonata-project/form-extensions` 2.0.
if (class_exists(CanonicalizeRuntime::class)) {
// @phpstan-ignore-next-line
return new ErrorElement(
'',
$this->createStub(ConstraintValidatorFactoryInterface::class),
$executionContext,
$this->createStub(ConstraintValidatorFactoryInterface::class), // @phpstan-ignore-line
$executionContext, // @phpstan-ignore-line
'group'
);
}

// @phpstan-ignore-next-line
return new ErrorElement('', $executionContext, 'group');
}

Expand Down
40 changes: 40 additions & 0 deletions tests/Resizer/SimpleResizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@ public static function getBoxSettings(): iterable
'resizer_options' => [],
], new Box(567, 200), new Box(100, 35)];

yield [ManipulatorInterface::THUMBNAIL_INSET, [
'width' => 1,
'height' => 1060,
'quality' => 80,
'format' => 'jpg',
'constraint' => true,
'resizer' => null,
'resizer_options' => [],
], new Box(567, 200), new Box(1, 1)];

yield [ManipulatorInterface::THUMBNAIL_INSET, [
'width' => 1060,
'height' => 1,
'quality' => 80,
'format' => 'jpg',
'constraint' => true,
'resizer' => null,
'resizer_options' => [],
], new Box(567, 200), new Box(3, 1)];

yield [ManipulatorInterface::THUMBNAIL_OUTBOUND, [
'width' => 90,
'height' => 90,
Expand Down Expand Up @@ -300,5 +320,25 @@ public static function getBoxSettings(): iterable
'resizer' => null,
'resizer_options' => [],
], new Box(567, 50), new Box(90, 8)];

yield [ManipulatorInterface::THUMBNAIL_OUTBOUND | ManipulatorInterface::THUMBNAIL_FLAG_UPSCALE, [
'width' => 1,
'height' => 1060,
'quality' => 80,
'format' => 'jpg',
'constraint' => true,
'resizer' => null,
'resizer_options' => [],
], new Box(50, 50), new Box(1, 1060)];

yield [ManipulatorInterface::THUMBNAIL_OUTBOUND | ManipulatorInterface::THUMBNAIL_FLAG_UPSCALE, [
'width' => 1060,
'height' => 1,
'quality' => 80,
'format' => 'jpg',
'constraint' => true,
'resizer' => null,
'resizer_options' => [],
], new Box(567, 50), new Box(1060, 1)];
}
}

0 comments on commit b5e897e

Please sign in to comment.