Skip to content

Commit 69f6e33

Browse files
committed
Fix tests II
1 parent c98d04f commit 69f6e33

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

src/EventSubscriber/Image/ImageCompressSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace App\EventSubscriber\Image;
66

77
use App\Event\ImagePostProcessEvent;
8-
use App\Service\ImageManager;
8+
use App\Service\ImageManagerInterface;
99
use App\Service\SettingsManager;
1010
use Psr\Log\LoggerInterface;
1111
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1212

1313
readonly class ImageCompressSubscriber implements EventSubscriberInterface
1414
{
1515
public function __construct(
16-
private ImageManager $imageManager,
16+
private ImageManagerInterface $imageManager,
1717
private SettingsManager $settingsManager,
1818
private LoggerInterface $logger,
1919
) {

src/Repository/EntryCommentRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function findImagesByEntry(Entry $entry): array
282282
->getQuery()
283283
->getResult();
284284

285-
return array_filter($results, fn (EntryComment $comment) => $comment->image);
285+
return array_map(fn (EntryComment $comment) => $comment->image, $results);
286286
}
287287

288288
public function hydrateChildren(EntryComment ...$comments): void

src/Repository/PostCommentRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function findImagesByPost(Post $post): array
205205
->getQuery()
206206
->getResult();
207207

208-
return array_filter($results, fn (PostComment $comment) => $comment->image);
208+
return array_map(fn (PostComment $comment) => $comment->image, $results);
209209
}
210210

211211
public function hydrateChildren(PostComment ...$comments): void

src/Service/ImageManagerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ public function getMimetype(\App\Entity\Image $image): string;
4141
* @throws FilesystemException
4242
*/
4343
public function deleteOrphanedFiles(ImageRepository $repository, bool $dryRun, array $ignoredPaths): iterable;
44+
45+
public function compressUntilSize(string $filePath, string $extension, int $maxBytes): bool;
4446
}

tests/Service/TestingImageManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,9 @@ public function deleteOrphanedFiles(ImageRepository $repository, bool $dryRun, a
108108
yield $deletedPath;
109109
}
110110
}
111+
112+
public function compressUntilSize(string $filePath, string $extension, int $maxBytes): bool
113+
{
114+
return $this->innerImageManager->compressUntilSize($filePath, $extension, $maxBytes);
115+
}
111116
}

0 commit comments

Comments
 (0)