Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Add compatibility with TYPO3 13 including tests #109

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ jobs:
typo3-versions: 11
- php-versions: 7.4
typo3-versions: 10
- php-versions: 8.2
typo3-versions: 13
- php-versions: 8.3
typo3-versions: 13
- php-versions: 8.4
typo3-versions: 13

name: Unit Testing (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
Expand Down Expand Up @@ -87,6 +93,13 @@ jobs:
matrix:
php-versions: [8.2, 8.1]
typo3-versions: [12]
include:
- php-versions: 8.2
typo3-versions: 13
- php-versions: 8.3
typo3-versions: 13
- php-versions: 8.4
typo3-versions: 13

name: Functional Testing (PHP ${{ matrix.php-versions }}, TYPO3 ${{ matrix.typo3-versions }})
steps:
Expand Down
6 changes: 3 additions & 3 deletions Classes/ViewHelpers/MediaViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public function initializeArguments(): void
public function render(): string
{
$file = $this->arguments['file'];
$additionalConfig = (array)$this->arguments['additionalConfig'];
$width = $this->arguments['width'];
$height = $this->arguments['height'];
$additionalConfig = (array)($this->arguments['additionalConfig'] ?? []);
$width = $this->arguments['width'] ?? '';
$height = $this->arguments['height'] ?? '';

// get Resource Object (non ExtBase version)
if (is_callable([$file, 'getOriginalResource'])) {
Expand Down
19 changes: 13 additions & 6 deletions Tests/Functional/ImageViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ public static function basicScalingCroppingDataProvider(): \Generator
150
];
// would be 200x150, but image will be stretched (why!?) up to have a width of 250
// @todo remove multiple possible heights when dropping support for versions before TYPO3 13
yield 'min width' => [
'<sms:image src="EXT:sms_responsive_images/Tests/Functional/Fixtures/ImageViewHelperTest.png" height="150" minWidth="250" />',
'@^<img src="(typo3temp/assets/_processed_/4/5/csm_ImageViewHelperTest_.*\.png)" width="250" height="150" alt="" />$@',
'@^<img src="(typo3temp/assets/_processed_/4/5/csm_ImageViewHelperTest_.*\.png)" width="250" height="(188|150)" alt="" />$@',
250,
150
[188, 150]
];
// would be 200x150, but image will be scaled down to have a width of 100
yield 'max width' => [
Expand All @@ -92,9 +93,11 @@ public static function basicScalingCroppingDataProvider(): \Generator
75
];
// would be 200x150, but image will be stretched (why!?) up to have a height of 200
// @todo remove multiple possible widths when dropping support for versions before TYPO3 13
yield 'min height' => [
'<sms:image src="EXT:sms_responsive_images/Tests/Functional/Fixtures/ImageViewHelperTest.png" width="200" minHeight="200" />',
'@^<img src="(typo3temp/assets/_processed_/4/5/csm_ImageViewHelperTest_.*\.png)" width="200" height="200" alt="" />$@',
'@^<img src="(typo3temp/assets/_processed_/4/5/csm_ImageViewHelperTest_.*\.png)" width="(267|200)" height="200" alt="" />$@',
[267, 200],
200,
200
];
Expand All @@ -108,10 +111,14 @@ public static function basicScalingCroppingDataProvider(): \Generator
}

/**
* @TODO convert parameters to `int` only when dropping support for versions before TYPO3 13
* @param int|int[] $expectedWidth
* @param int|int[] $expectedHeight
*
* @test
* @dataProvider basicScalingCroppingDataProvider
*/
public function basicScalingCropping(string $template, string $expected, int $expectedWidth, int $expectedHeight): void
public function basicScalingCropping(string $template, string $expected, $expectedWidth, $expectedHeight): void
{
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplateSource('<html
Expand All @@ -133,8 +140,8 @@ public function basicScalingCropping(string $template, string $expected, int $ex
$matches = [];
preg_match($expected, $result, $matches);
list($width, $height) = getimagesize($this->instancePath . '/' . $matches[1]);
self::assertEquals($expectedWidth, $width, 'width of generated image does not match expected width');
self::assertEquals($expectedHeight, $height, 'height of generated image does not match expected height');
self::assertContains($width, is_array($expectedWidth) ? $expectedWidth : [$expectedWidth], 'width of generated image does not match expected width');
self::assertContains($height, is_array($expectedHeight) ? $expectedHeight : [$expectedHeight], 'height of generated image does not match expected height');
}

public static function cropVariantCollectionDataProvider(): \Generator
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"issues": "https://github.com/sitegeist/sms-responsive-images/issues"
},
"require": {
"typo3/cms-core": "^12.2 || ^11.5 || ^10.4"
"typo3/cms-core": "^13.1 || ^12.2 || ^11.5 || ^10.4"
},
"require-dev": {
"typo3/testing-framework": "^7.0 || ^6.0 || dev-main",
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'version' => '3.0.0',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-12.9.99',
'typo3' => '10.4.0-13.9.99',
],
'conflicts' => [
],
Expand Down