• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / progressive-image-bundle / 20691139798

04 Jan 2026 09:53AM UTC coverage: 89.247%. Remained the same
20691139798

push

github

tito10047
update responsive image generation tests: refine test cases to ensure URLs are generated for duplicate widths, adjust srcset expectations for larger breakpoints, fix responsive styles validation, and add new fixtures for improved test coverage

2 of 2 new or added lines in 1 file covered. (100.0%)

4 existing lines in 1 file now uncovered.

664 of 744 relevant lines covered (89.25%)

229.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/Controller/LiipImagineController.php
1
<?php
2

3
/*
4
 * This file is part of the Progressive Image Bundle.
5
 *
6
 * (c) Jozef Môstka <https://github.com/tito10047/progressive-image-bundle>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
declare(strict_types=1);
12

13
namespace Tito10047\ProgressiveImageBundle\Controller;
14

15
use Liip\ImagineBundle\Config\Controller\ControllerConfig;
16
use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException;
17
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
18
use Liip\ImagineBundle\Imagine\Cache\Helper\PathHelper;
19
use Liip\ImagineBundle\Imagine\Data\DataManager;
20
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
21
use Liip\ImagineBundle\Service\FilterService;
22
use Symfony\Component\HttpFoundation\RedirectResponse;
23
use Symfony\Component\HttpFoundation\Request;
24
use Symfony\Component\HttpFoundation\Response;
25
use Symfony\Component\HttpFoundation\UriSigner;
26
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
27
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
28
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
29
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGeneratorInterface;
30
use Tito10047\ProgressiveImageBundle\Service\MetadataReaderInterface;
31

32
final class LiipImagineController
33
{
34
    public function __construct(
35
        private readonly UriSigner $signer,
36
        private readonly FilterService $filterService,
37
        private readonly DataManager $dataManager,
38
        private readonly FilterConfiguration $filterConfiguration,
39
        private readonly ControllerConfig $controllerConfig,
40
        private readonly LiipImagineRuntimeConfigGeneratorInterface $runtimeConfigGenerator,
41
        private readonly MetadataReaderInterface $metadataReader,
42
    ) {
43
    }
98✔
44

45
    public function index(
46
        Request $request,
47
        #[MapQueryParameter] string $path,
48
        #[MapQueryParameter] int $width,
49
        #[MapQueryParameter] int $height,
50
        #[MapQueryParameter] ?string $filter = null,
51
        #[MapQueryParameter] ?string $pointInterest = null,
52
    ): Response {
53
        $path = PathHelper::urlPathToFilePath($path);
98✔
54

55
        $origWidth = null;
98✔
56
        $origHeight = null;
98✔
57
        if ($pointInterest) {
98✔
58
            $metadata = $this->metadataReader->getMetadata($path);
28✔
59
            $origWidth = $metadata->width;
28✔
60
            $origHeight = $metadata->height;
28✔
61
        }
62

63
        $result = $this->runtimeConfigGenerator->generate($width, $height, $filter, $pointInterest, $origWidth, $origHeight);
98✔
64
        $filterName = $result['filterName'];
98✔
65
        $config = $result['config'];
98✔
66

67
        $this->filterConfiguration->set($filterName, $config);
98✔
68

69
        if (true !== $this->signer->checkRequest($request)) {
98✔
70
            throw new BadRequestHttpException(\sprintf('Signed url does not pass the sign check for path "%s" and filter "%s"', $path, $filter));
×
71
        }
72

73
        return $this->createRedirectResponse(function () use ($path, $filterName) {
98✔
74
                        $url = $this->filterService->getUrlOfFilteredImage($path, $filterName);
98✔
75

76
                        return str_replace('/resolve/', '/', $url);
98✔
77
        }, $path, $filterName);
98✔
78
    }
79

80
    private function createRedirectResponse(\Closure $url, string $path, string $filter): RedirectResponse
81
    {
82
        try {
83
            return new RedirectResponse($url(), $this->controllerConfig->getRedirectResponseCode());
98✔
84
        } catch (NotLoadableException $exception) {
×
UNCOV
85
            if (null !== $this->dataManager->getDefaultImageUrl($filter)) {
×
UNCOV
86
                return new RedirectResponse($this->dataManager->getDefaultImageUrl($filter));
×
87
            }
88

89
            throw new NotFoundHttpException(\sprintf('Source image for path "%s" could not be found', $path), $exception);
×
90
        } catch (NonExistingFilterException $exception) {
×
91
            throw new NotFoundHttpException(\sprintf('Requested non-existing filter "%s"', $filter), $exception);
×
UNCOV
92
        } catch (\RuntimeException $exception) {
×
UNCOV
93
            throw new \RuntimeException(\sprintf('Unable to create image for path "%s" and filter "%s". Message was "%s"', $path, $filter, $exception->getMessage()), 0, $exception);
×
94
        }
95
    }
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc