Skip to content

Commit

Permalink
Merge branch '3.0' into 3
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 14, 2025
2 parents 688c72e + 4f97a68 commit 153ffc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ImageManipulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,16 @@ public function ThumbnailURL($width, $height)
*/
public function Convert(string $toExtension): ?AssetContainer
{
// Verify this manipulation is applicable to this instance
if (!$this->exists()) {
return null;
}
$converter = Injector::inst()->get(FileConverterManager::class);
try {
return $converter->convert($this, $toExtension);
} catch (FileConverterException $e) {
/** @var LoggerInterface $logger */
$logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler');
$logger = Injector::inst()->get(LoggerInterface::class);
$logger->error($e->getMessage());
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion tests/php/ImageManipulationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public function testConvert(string $originalFileFixtureClass, string $originalFi
$mockLogger = $this->getMockBuilder(Logger::class)->setConstructorArgs(['testLogger'])->getMock();
$mockLogger->expects($success ? $this->never() : $this->once())
->method('error');
Injector::inst()->registerService($mockLogger, LoggerInterface::class . '.errorhandler');
Injector::inst()->registerService($mockLogger, LoggerInterface::class);

$result = $file->Convert($toExtension);

Expand All @@ -604,6 +604,12 @@ public function testConvert(string $originalFileFixtureClass, string $originalFi
}
}

public function testConvertEmpty(): void
{
$file = new Image();
$this->assertNull($file->Convert('webp'));
}

public static function provideConvertChainWithLazyLoad(): array
{
return [
Expand Down

0 comments on commit 153ffc2

Please sign in to comment.