Skip to content

Commit

Permalink
!!! [TASK] change requirements
Browse files Browse the repository at this point in the history
* drop TYPO3 10 Support
* add TYPO3 13 Support
  • Loading branch information
achimfritz-b13 committed May 24, 2024
1 parent 2a88bba commit e473ccf
Show file tree
Hide file tree
Showing 27 changed files with 108 additions and 148 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.4', '8.0', '8.1' ]
TYPO3: [ '11' ]
include:
- TYPO3: '10'
php: '7.4'
- TYPO3: '12'
php: '8.1'
php: [ '8.3' ]
TYPO3: [ '11', '12' , '13' ]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Patch 10
if: matrix.TYPO3 == '10'
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s patchV10

- name: Install testing system
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s composerInstall

Expand All @@ -41,7 +33,7 @@ jobs:
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s cgl -n

- name: phpstan
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s phpstan
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s phpstan

- name: Unit Tests
run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s unit
Expand Down
6 changes: 0 additions & 6 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,6 @@ case ${TEST_SUITE} in
SUITE_EXIT_CODE=$?
docker-compose down
;;
patchV10)
setUpDockerComposeDotEnv
docker-compose run patchV10
SUITE_EXIT_CODE=$?
docker-compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
Expand Down
7 changes: 7 additions & 0 deletions Build/phpstan11.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 5

paths:
- %currentWorkingDirectory%/Classes
ignoreErrors:
- '#.*unknown class TYPO3\\CMS\\Core\\TypoScript\\FrontendTypoScript.#'
34 changes: 6 additions & 28 deletions Build/phpunit/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,12 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Information\Typo3Version;

call_user_func(function () {
if (!class_exists(\TYPO3\CMS\Frontend\Page\PageRepository::class)) {
class_alias(\TYPO3\CMS\Core\Domain\Repository\PageRepository::class, \TYPO3\CMS\Frontend\Page\PageRepository::class);
}
$testbase = new \TYPO3\TestingFramework\Core\Testbase();

// These if's are for core testing (package typo3/cms) only. cms-composer-installer does
// not create the autoload-include.php file that sets these env vars and sets composer
// mode to true. testing-framework can not be used without composer anyway, so it is safe
// to do this here. This way it does not matter if 'bin/phpunit' or 'vendor/phpunit/phpunit/phpunit'
// is called to run the tests since the 'relative to entry script' path calculation within
// SystemEnvironmentBuilder is not used. However, the binary must be called from the document
// root since getWebRoot() uses 'getcwd()'.
if (!getenv('TYPO3_PATH_ROOT')) {
putenv('TYPO3_PATH_ROOT=' . rtrim($testbase->getWebRoot(), '/'));
}
if (!getenv('TYPO3_PATH_WEB')) {
putenv('TYPO3_PATH_WEB=' . rtrim($testbase->getWebRoot(), '/'));
}

$testbase->defineSitePath();

$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
Expand All @@ -56,18 +40,12 @@ class_alias(\TYPO3\CMS\Core\Domain\Repository\PageRepository::class, \TYPO3\CMS\
'core',
new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
);
// Set all packages to active
if (version_compare((new Typo3Version())->getVersion(), '11.3.0', '>')) {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
\TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)
);
} else {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
$cache
);
}

$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
\TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)
);

\TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);

Expand Down
30 changes: 8 additions & 22 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ services:
fi
php -v | grep '^PHP';
if [ ${TYPO3} -eq 11 ]; then
composer install --no-progress --no-interaction
elif [ ${TYPO3} -eq 10 ]; then
composer require friendsofphp/php-cs-fixer:~3.9.0 typo3/cms-fluid:^10.4 typo3/testing-framework:^6 --dev -W --no-progress --no-interaction
composer prepare-tests-10
else
composer require typo3/cms-fluid:^11.5 --dev -W --no-progress --no-interaction
elif [ ${TYPO3} -eq 12 ]; then
composer require typo3/cms-fluid:^12.4 --dev -W --no-progress --no-interaction
else
composer install --dev --no-progress --no-interaction
fi
"
Expand Down Expand Up @@ -165,23 +164,6 @@ services:
find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -dxdebug.mode=off -l >/dev/null
"
patchV10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)testExtensionsToLoad = \[/protected \1testExtensionsToLoad = [/g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected bool \(.*\)resetSingletonInstances = /protected \1resetSingletonInstances = /g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)coreExtensionsToLoad = \[/protected \1coreExtensionsToLoad = [/g';
find Tests -name \\*.php -print0 | xargs -0 sed -i 's/protected array \(.*\)pathsToLinkInTestInstance = \[/protected \1pathsToLinkInTestInstance = [/g';
"
phpstan:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
Expand All @@ -197,7 +179,11 @@ services:
set -x
fi
php -v | grep '^PHP';
if [ ${TYPO3} -eq 11 ]; then
php -dxdebug.mode=off .Build/bin/phpstan analyze -c Build/phpstan11.neon --no-progress --no-interaction
else
php -dxdebug.mode=off .Build/bin/phpstan analyze -c Build/phpstan.neon --no-progress --no-interaction
fi
"
unit:
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/PictureConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(array $arguments, array $typoScriptSettings, FileInt
$this->lazyLoading = (string)$typoScriptSettings['lazyLoading'];
}
// do not add retina images for elements with variants (the browser should select the best-sized image)
if(!empty($arguments['sizes'])) {
if (!empty($arguments['sizes'])) {
$this->useRetina = false;
}
}
Expand Down
25 changes: 22 additions & 3 deletions Classes/ViewHelpers/ImageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
*/

use B13\Picture\Domain\Model\PictureConfiguration;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Resource\FileInterface;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Service\ImageService;
Expand Down Expand Up @@ -461,13 +464,29 @@ protected function buildOutput(array $output): string
protected function getTypoScriptSettings(): array
{
$settings = [];
$frontendController = $this->getFrontendController();
if ($frontendController instanceof TypoScriptFrontendController) {
$settings = $frontendController->tmpl->setup['plugin.']['tx_picture.'] ?? [];
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) {
$frontendController = $this->getFrontendController();
if ($frontendController instanceof TypoScriptFrontendController) {
$settings = $frontendController->tmpl->setup['plugin.']['tx_picture.'] ?? [];
}
return $settings;
}
$request = $this->getServerRequest();
if ($request === null) {
return $settings;
}
/** @var FrontendTypoScript $typoScript */
$typoScript = $request->getAttribute('frontend.typoscript');
$setup = $typoScript->getSetupArray();
$settings = $setup['plugin.']['tx_picture.'] ?? [];
return $settings;
}

protected function getServerRequest(): ?ServerRequestInterface
{
return $GLOBALS['TYPO3_REQUEST'] ?? null;
}

protected function getFrontendController(): ?TypoScriptFrontendController
{
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) {
Expand Down
32 changes: 0 additions & 32 deletions Tests/Functional/Frontend/AbstractFrontendTest.php

This file was deleted.

9 changes: 6 additions & 3 deletions Tests/Functional/Frontend/DemonstrationPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
* of the License, or any later version.
*/

use B13\Picture\Tests\Functional\Functional\AbstractFrontendTest;
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;

class ImageViewHelperTest extends AbstractFrontendTest
class DemonstrationPageTest extends FunctionalTestCase
{
protected array $pathsToLinkInTestInstance = ['typo3conf/ext/picture/Build/sites' => 'typo3conf/sites'];
protected array $testExtensionsToLoad = ['typo3conf/ext/picture'];

/**
* @test
*/
Expand All @@ -30,7 +33,7 @@ public function callingPageReturns200ResponseCode(): void
'setup' => ['EXT:picture/Configuration/TypoScript/test.typoscript'],
]
);
$response = $this->executeFrontendRequest(new InternalRequest('/?type=1573387706874'));
$response = $this->executeFrontendSubRequest(new InternalRequest('http://localhost/?type=1573387706874'));
$status = $response->getStatusCode();
self::assertSame(200, $status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
>
<f:spaceless>
<i:image src="EXT:picture/Resources/Public/Test/Picture.png" width="400" alt="Testimage 400px width" />
</f:spaceless>
</f:spaceless>
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithMultipleSizes.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithMultipleSources.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithMultipleSourcesWithWebpOption.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithPictureClass.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithSrcsetAndASizesValueWithWebpOption.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithThreeSizesForThreeGivenBreakpoints.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = ImageWithTwoSizesAndRetinaOption.html
"
config.absRefPrefix = /
"
3 changes: 2 additions & 1 deletion Tests/Functional/Frontend/Fixtures/simple_image.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SimpleImage.html
"
config.absRefPrefix = /
"
3 changes: 2 additions & 1 deletion Tests/Functional/Frontend/Fixtures/simple_image_as_webp.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SimpleImageAsWebp.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SimpleImageWithRetinaAndWebpOption.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SimpleImageWithRetinaOption.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SimpleImageWithWebpOption.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SingleImageWithMultipleImageSizesAndTwoBreakpoints.html
"
config.absRefPrefix = /
"
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ page.config.disableAllHeaderCode = 1
page.10 = FLUIDTEMPLATE
page.10.templateRootPaths.10 = EXT:picture/Tests/Functional/Frontend/Fixtures/Templates
page.10.templateName = SingleImageWithMultipleImageSizesAsSrcset.html
"
config.absRefPrefix = /
"
Loading

0 comments on commit e473ccf

Please sign in to comment.