Skip to content

Commit

Permalink
[FEATURE] add test for WebP auto conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichmathes committed Jan 3, 2025
1 parent 432413d commit 6bb40c2
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions Tests/Functional/ImageComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public static function imageComponentTestProvider(): array
return [
'Only mandatory data provided' => [
'<img src="fileadmin/test_files/image.png" height="3840" width="3840" />',
'<fc:image src="5" />'
'<fc:image src="5" />',
'',
],
'All data provided' => [
'<img src="fileadmin/_processed_/3/8/csm_image_3c73179ad3.jpg" srcset="fileadmin/_processed_/3/8/csm_image_2fe057fbe4.jpg 400w, fileadmin/_processed_/3/8/csm_image_00a46099c0.jpg 800w, fileadmin/_processed_/3/8/csm_image_622ce9e0c0.jpg 1200w" height="100" width="100" alt="Alt text" title="Title text" loading="lazy" sizes="(min-width: 400px) 400px, (min-width: 800px) 800px, (min-width:1200px) 1200px, 100vw" />',
Expand All @@ -32,17 +33,33 @@ public static function imageComponentTestProvider(): array
title="Title text"
lazyload="true"
preload="true"
/>'
]
/>',
'',
],
'Active WebP auto conversion' => [
'<img src="fileadmin/_processed_/3/8/csm_image_4458ca8493.webp" height="3840" width="3840" />',
'<fc:image src="5" />',
'jpeg, png',
],
'Forced Format WebP auto conversion' => [
'<img src="fileadmin/test_files/image.png" height="3840" width="3840" />',
'<fc:image src="5" format="png" />',
'jpeg, png',
],
'Not applying WebP auto conversion' => [
'<img src="fileadmin/test_files/image.png" height="3840" width="3840" />',
'<fc:image src="5" />',
'jpeg, ai',
],
];
}

#[Test]
#[DataProvider('imageComponentTestProvider')]
public function imageComponentTest(string $expectedResult, string $input): void {
public function imageComponentTest(string $expectedResult, string $input, string $autoWebpConversionFormats): void {
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['media_components']['autoWebpConversionFormats'] = $autoWebpConversionFormats;
$view = $this->getTestView($input);
$result = $this->cleanUpTestResult($view->render());

$this->assertStringContainsString($expectedResult, $result);
}
}

0 comments on commit 6bb40c2

Please sign in to comment.