From 7079ce80eef412c88247329ad1e5199df5dca1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 16:45:17 +0100 Subject: [PATCH 01/16] [TASK] Remove last traces for PHPUnit 9.x support Dual PHPUnit 9.x and 10.x support with `typo3/testing-framework` v7 has been used in previous versions to allow testing for the full TYPO3 version range. Due to dropped TYPO3 v11 support, we can use PHPUnit 10.x completly, which has been prepared with the next major version preparation. This change removes the last dual version support switches, removes the PHPUnit 9.x configuration files and normalizes this to a single PHPUnit version usage. --- Build/Scripts/runTests.sh | 12 ++---- Build/phpunit/FunctionalTests-10.xml | 59 ---------------------------- Build/phpunit/FunctionalTests.xml | 45 ++++++++++----------- Build/phpunit/UnitTests-10.xml | 52 ------------------------ Build/phpunit/UnitTests.xml | 51 +++++++++++------------- composer.json | 4 +- 6 files changed, 49 insertions(+), 174 deletions(-) delete mode 100644 Build/phpunit/FunctionalTests-10.xml delete mode 100644 Build/phpunit/UnitTests-10.xml diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 430fdd8f..e8567ce3 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -524,9 +524,7 @@ case ${TEST_SUITE} in SUITE_EXIT_CODE=$? ;; functional) - PHPUNIT_CONFIG_FILE="Build/phpunit/FunctionalTests-10.xml" - # @todo Remove version switch after TYPO3 v11 / phpunit 9 support has been dropped. - [[ "${CORE_VERSION}" -eq 11 ]] && PHPUNIT_CONFIG_FILE="Build/phpunit/FunctionalTests.xml" + PHPUNIT_CONFIG_FILE="Build/phpunit/FunctionalTests.xml" COMMAND=(.Build/bin/phpunit -c ${PHPUNIT_CONFIG_FILE} --exclude-group not-${DBMS} "$@") echo "Using deepl-mockserver" ${CONTAINER_BIN} run --rm ${CI_PARAMS} --name deepl-func-${SUFFIX} --network ${NETWORK} -d ${IMAGE_DEEPL} >/dev/null @@ -600,17 +598,13 @@ case ${TEST_SUITE} in SUITE_EXIT_CODE=$? ;; unit) - PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests-10.xml" - # @todo Remove version switch after TYPO3 v11 / phpunit 9 support has been dropped. - [[ "${CORE_VERSION}" -eq 11 ]] && PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests.xml" + PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests.xml" COMMAND=(.Build/bin/phpunit -c ${PHPUNIT_CONFIG_FILE} "$@") ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name unit-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_PHP} "${COMMAND[@]}" SUITE_EXIT_CODE=$? ;; unitRandom) - PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests-10.xml" - # @todo Remove version switch after TYPO3 v11 / phpunit 9 support has been dropped. - [[ "${CORE_VERSION}" -eq 11 ]] && PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests.xml" + PHPUNIT_CONFIG_FILE="Build/phpunit/UnitTests.xml" COMMAND=(.Build/bin/phpunit -c ${PHPUNIT_CONFIG_FILE} --order-by=random ${PHPUNIT_RANDOM} "$@") ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name unit-random-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_PHP} "${COMMAND[@]}" SUITE_EXIT_CODE=$? diff --git a/Build/phpunit/FunctionalTests-10.xml b/Build/phpunit/FunctionalTests-10.xml deleted file mode 100644 index 10526d42..00000000 --- a/Build/phpunit/FunctionalTests-10.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - ../../Tests/Functional/ - - - - - - - - - - - diff --git a/Build/phpunit/FunctionalTests.xml b/Build/phpunit/FunctionalTests.xml index a5ab32d2..10526d42 100644 --- a/Build/phpunit/FunctionalTests.xml +++ b/Build/phpunit/FunctionalTests.xml @@ -13,35 +13,33 @@ TYPO3 CMS functional test suite also needs phpunit bootstrap code, the file is located next to this .xml as FunctionalTestsBootstrap.php - phpunit v9 compatible version, use -10.xml file for phpunit 10. + phpunit v10.1 compatible version. --> + This path either needs an adaption in extensions, or an extension's + test location path needs to be given to phpunit. + --> ../../Tests/Functional/ @@ -49,13 +47,12 @@ - + @deprecated: Set this to not suppress warnings, notices and deprecations in functional tests + with TYPO3 core v11 and up. + Will always be done with next major version. + To still suppress warnings, notices and deprecations, do NOT define the constant at all. + --> + diff --git a/Build/phpunit/UnitTests-10.xml b/Build/phpunit/UnitTests-10.xml deleted file mode 100644 index b51ee54f..00000000 --- a/Build/phpunit/UnitTests-10.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - ../../Tests/Unit/ - - - - - - - - - diff --git a/Build/phpunit/UnitTests.xml b/Build/phpunit/UnitTests.xml index 059c5554..b51ee54f 100644 --- a/Build/phpunit/UnitTests.xml +++ b/Build/phpunit/UnitTests.xml @@ -13,43 +13,40 @@ TYPO3 CMS functional test suite also needs phpunit bootstrap code, the file is located next to this .xml as FunctionalTestsBootstrap.php - phpunit v9 compatible version, use -10.xml file for phpunit 10. + phpunit v10.1 compatible version. --> - - - - ../../Tests/Unit/ - - - - - - - - + ../../Tests/Unit/ + + + + + + + + diff --git a/composer.json b/composer.json index 346644de..f8b13ee1 100644 --- a/composer.json +++ b/composer.json @@ -142,8 +142,6 @@ "@test:php:functional" ], "test:php:unit": "@phpunit --colors=always --configuration Build/phpunit/UnitTests.xml", - "test:php:functional": "@test:php:unit --configuration Build/phpunit/FunctionalTests.xml", - "test:php:unit10": "@phpunit --colors=always --configuration Build/phpunit/UnitTests-10.xml", - "test:php:functional10": "@test:php:unit --configuration Build/phpunit/FunctionalTests-10.xml" + "test:php:functional": "@test:php:unit --configuration Build/phpunit/FunctionalTests.xml" } } From 445ca8f80c3cbcaa89d753645442ea456896b785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 16:50:12 +0100 Subject: [PATCH 02/16] [TASK] Remove php version guard for lintTypoScript in `Build/Scripts/runTests.sh` Due to some issues of the TypoScript linter a PHPVersion guard has been added in `Build/Scripts/runTests.sh`. Minimum PHP version has been raised while preparing for the next major version and made the aforementioned check obsolete and is now removed. --- Build/Scripts/runTests.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index e8567ce3..9049ebef 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -568,15 +568,6 @@ case ${TEST_SUITE} in SUITE_EXIT_CODE=$? ;; lintTypoScript) - # @todo Remove this after a working version for lower php has been released OR minimum PHP version raised. - # @see https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-96812-OverrideBackendTemplatesWithTSconfig.html - if [ "${PHP_VERSION}" == "7.4" -o "${PHP_VERSION}" == "7.4" ]; then - echo " ERROR: Wrong php version ${PHP_VERSION}" - echo " -t -s lintTypoScript requires to be executed at least with PHP8.1 with a proper" - echo " -t -s composerUpdate run before to retrieve a linter version which can deal with" - echo " TYPO3 v12 PageTSConfig backend template override syntax" - exit 1 - fi COMMAND="php -dxdebug.mode=off .Build/bin/typoscript-lint --ansi --config=./Build/typoscript-lint/typoscript-lint.yml" ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name lint-php-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} /bin/sh -c "${COMMAND}" SUITE_EXIT_CODE=$? From ed5c58b2491ebe1c3db5cb51c4c0fdc3be67adfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:06:26 +0100 Subject: [PATCH 03/16] [TASK] Add native typing for `Build/Scripts/validateRstFiles.php` --- Build/Scripts/validateRstFiles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Build/Scripts/validateRstFiles.php b/Build/Scripts/validateRstFiles.php index bf459773..2f5f5ada 100755 --- a/Build/Scripts/validateRstFiles.php +++ b/Build/Scripts/validateRstFiles.php @@ -58,7 +58,7 @@ public function __construct(string $dir = '') } } - public function validate() + public function validate(): void { printf('Searching for rst snippets in ' . $this->baseDir . chr(10)); @@ -171,14 +171,14 @@ protected function validateContent(string $fileContent) $this->validateLinkTarget($fileContent); } - private function setError(array $config) + private function setError(array $config): void { $this->messages[$config['type']]['title'] = $config['title']; $this->messages[$config['type']]['message'] = $config['message']; $this->isError = true; } - private function validateLinkTarget(string $fileContent) + private function validateLinkTarget(string $fileContent): void { $linkTargetConfig = [ 'type' => 'linktarget', From 6f08b3d4c2a26a1f7ff76a0d0293c6c205c0cce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:08:24 +0100 Subject: [PATCH 04/16] [TASK] Ensure correct `ext_emconf.php` for `test_services_override` This change ensures correct `ext_emconf.php` for the test fixture extension `test_services_override`. --- .../Fixtures/Extensions/test_services_override/ext_emconf.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/Functional/Fixtures/Extensions/test_services_override/ext_emconf.php b/Tests/Functional/Fixtures/Extensions/test_services_override/ext_emconf.php index a315f6ba..3d611e8c 100644 --- a/Tests/Functional/Fixtures/Extensions/test_services_override/ext_emconf.php +++ b/Tests/Functional/Fixtures/Extensions/test_services_override/ext_emconf.php @@ -21,7 +21,8 @@ 'version' => '1.0.0.', 'constraints' => [ 'depends' => [ - 'typo3' => '11.5.0-12.4.99', + 'typo3' => '12.4.0-12.4.99', + 'deepltranslate_core' => '*', ], 'conflicts' => [], 'suggests' => [], From 94636c97899ded9eaf74484ad26566de38456d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:18:05 +0100 Subject: [PATCH 05/16] [TASK] Use camelcase extension key for extbase `LocalizationUtility` calls Extbase `LocalizationUtility` expectes the extension key in camelcase typing and converts to the lower cased extension key with underscores automatically. Use camelcase writing now in for `LocalizationUtility` calls. --- Classes/Controller/GlossarySyncController.php | 10 +++++----- Classes/Event/Listener/GlossarySyncButtonProvider.php | 2 +- Classes/Hooks/ButtonBarHook.php | 2 +- .../Hooks/Glossary/UpdatedGlossaryEntryTermHook.php | 4 ++-- Classes/Override/Core12/DeeplRecordListController.php | 2 +- Classes/Utility/DeeplBackendUtility.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Classes/Controller/GlossarySyncController.php b/Classes/Controller/GlossarySyncController.php index dd097677..a2cb53af 100644 --- a/Classes/Controller/GlossarySyncController.php +++ b/Classes/Controller/GlossarySyncController.php @@ -58,7 +58,7 @@ public function update(ServerRequestInterface $request): RedirectResponse sprintf('Page "%d" not configured for glossary synchronization.', $pages['uid']), (string)LocalizationUtility::translate( 'glossary.sync.title.invalid', - 'deepltranslate_core' + 'DeepltranslateCore' ), 2, true @@ -69,15 +69,15 @@ public function update(ServerRequestInterface $request): RedirectResponse try { $this->deeplGlossaryService->syncGlossaries((int)$processingParameters['uid']); $this->flashMessageService->getMessageQueueByIdentifier()->enqueue(new FlashMessage( - (string)LocalizationUtility::translate('glossary.sync.message', 'deepltranslate_core'), - (string)LocalizationUtility::translate('glossary.sync.title', 'deepltranslate_core'), + (string)LocalizationUtility::translate('glossary.sync.message', 'DeepltranslateCore'), + (string)LocalizationUtility::translate('glossary.sync.title', 'DeepltranslateCore'), 0, // OK true )); } catch (FailedToCreateGlossaryException $exception) { $this->flashMessageService->getMessageQueueByIdentifier()->enqueue(new FlashMessage( - (string)LocalizationUtility::translate('glossary.sync.message.invalid', 'deepltranslate_core'), - (string)LocalizationUtility::translate('glossary.sync.title.invalid', 'deepltranslate_core'), + (string)LocalizationUtility::translate('glossary.sync.message.invalid', 'DeepltranslateCore'), + (string)LocalizationUtility::translate('glossary.sync.title.invalid', 'DeepltranslateCore'), 2, // Error true )); diff --git a/Classes/Event/Listener/GlossarySyncButtonProvider.php b/Classes/Event/Listener/GlossarySyncButtonProvider.php index b900ff84..9db6122f 100644 --- a/Classes/Event/Listener/GlossarySyncButtonProvider.php +++ b/Classes/Event/Listener/GlossarySyncButtonProvider.php @@ -66,7 +66,7 @@ public function __invoke(ModifyButtonBarEvent $event): void $parameters = $this->buildParamsArrayForListView((int)$id); $title = (string)LocalizationUtility::translate( 'glossary.sync.button.all', - 'deepltranslate_core' + 'DeepltranslateCore' ); // Style button $iconFactory = GeneralUtility::makeInstance(IconFactory::class); diff --git a/Classes/Hooks/ButtonBarHook.php b/Classes/Hooks/ButtonBarHook.php index c73d3996..bb4b4ae7 100644 --- a/Classes/Hooks/ButtonBarHook.php +++ b/Classes/Hooks/ButtonBarHook.php @@ -56,7 +56,7 @@ public function getButtons(array $params, ButtonBar $buttonBar): array $parameters = $this->buildParamsArrayForListView((int)$page['uid']); $title = (string)LocalizationUtility::translate( 'glossary.sync.button.all', - 'deepltranslate_core' + 'DeepltranslateCore' ); // Style button $iconFactory = GeneralUtility::makeInstance(IconFactory::class); diff --git a/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php b/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php index 9de07f3d..fd87551c 100644 --- a/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php +++ b/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php @@ -63,11 +63,11 @@ public function processDatamap_afterDatabaseOperations( $flashMessage = new FlashMessage( (string)LocalizationUtility::translate( 'glossary.not-sync.message', - 'deepltranslate_core' + 'DeepltranslateCore' ), (string)LocalizationUtility::translate( 'glossary.not-sync.title', - 'deepltranslate_core' + 'DeepltranslateCore' ), AbstractMessage::INFO, true diff --git a/Classes/Override/Core12/DeeplRecordListController.php b/Classes/Override/Core12/DeeplRecordListController.php index 6a366f0d..adbc1748 100644 --- a/Classes/Override/Core12/DeeplRecordListController.php +++ b/Classes/Override/Core12/DeeplRecordListController.php @@ -136,7 +136,7 @@ private function buildGlossaryTranslationOptionDropdown(array $siteLanguages, st $output = ''; diff --git a/Classes/Utility/DeeplBackendUtility.php b/Classes/Utility/DeeplBackendUtility.php index be2927a8..74c09e9a 100644 --- a/Classes/Utility/DeeplBackendUtility.php +++ b/Classes/Utility/DeeplBackendUtility.php @@ -93,7 +93,7 @@ public static function buildTranslateButton( $title = (string)LocalizationUtility::translate( 'backend.button.translate', - 'deepltranslate_core', + 'DeepltranslateCore', [ htmlspecialchars($languageTitle), ] @@ -208,7 +208,7 @@ public static function buildTranslateDropdown( if ($output !== '') { $output = sprintf( '%s', - htmlspecialchars((string)LocalizationUtility::translate('backend.label', 'deepltranslate_core')), + htmlspecialchars((string)LocalizationUtility::translate('backend.label', 'DeepltranslateCore')), $output ); } From 48c5026f74c37818003644fbaf5c12b545fbe93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:21:51 +0100 Subject: [PATCH 06/16] [TASK] Avoid deprecated Doctrine DBAL methods After dropping TYPO3 v11 support, we can safely assume the new Doctrine DBAL methods, having at least Doctrine DBAL 3.x on board. Use `fetchAssociative()` instead of deprecated method `fetch()` to retrieve a single record. --- Tests/Functional/Hooks/TranslateHookTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/Functional/Hooks/TranslateHookTest.php b/Tests/Functional/Hooks/TranslateHookTest.php index 922ad8b6..85c55f63 100644 --- a/Tests/Functional/Hooks/TranslateHookTest.php +++ b/Tests/Functional/Hooks/TranslateHookTest.php @@ -189,8 +189,11 @@ public function translateContentElementsAndUpdatePagesProperties(): void 'pages', [ 'uid' => 2, - ] - )->fetch(); + ], + [], + [], + 1, + )->fetchAssociative(); static::assertArrayHasKey('tx_wvdeepltranslate_content_not_checked', $pageRow); static::assertSame(1, (int)$pageRow['tx_wvdeepltranslate_content_not_checked']); From 1da69ea769390e4c155d65f22d2ce43ba7efffa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:41:32 +0100 Subject: [PATCH 07/16] [TASK] Remove `cruser_id` configuration support With TYPO3 12.0 the `cruser_id` TCA configuration feature has been removed completly. That has been covered for dual TYPO3 v11/v12 support previously within the TCA and TCAOverride files connected to `Typo3Version->getMajorVersion()` checks. Not having to support TYPO3 v11 anymore, this change removes the configuration completly. * https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98024-TCA-option-cruserid-removed.html --- .../tx_wvdeepltranslate_glossary.php | 26 ------------------- .../TCA/tx_wvdeepltranslate_glossary.php | 1 - .../TCA/tx_wvdeepltranslate_glossaryentry.php | 1 - 3 files changed, 28 deletions(-) delete mode 100644 Configuration/TCA/Overrides/tx_wvdeepltranslate_glossary.php diff --git a/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossary.php b/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossary.php deleted file mode 100644 index 34a17726..00000000 --- a/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossary.php +++ /dev/null @@ -1,26 +0,0 @@ -getMajorVersion() >= 12) { - // Adjust TCA configuration to be TYPO3 v12 compatible avoiding TCA automigration. - // 1. https://review.typo3.org/c/Packages/TYPO3.CMS/+/77626 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Deprecation-99739-IndexedArrayKeysForTCAItems.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Feature-99739-AssociativeArrayKeysForTCAItems.html - // => Directly solved in `Configuration/TCA/tx_wvdeepltranslate_glossary.php as version check. - // 2. https://review.typo3.org/c/Packages/TYPO3.CMS/+/73709 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97035-RequiredOptionInEvalKeyword.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97035-UtilizeRequiredDirectlyInTCAFieldConfiguration.html - // => not needed for this table (yet) - // 3. https://review.typo3.org/c/Packages/TYPO3.CMS/+/75123 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98024-TCA-option-cruserid-removed.html - // 4. https://review.typo3.org/c/Packages/TYPO3.CMS/+/74027 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97232-NewTCATypeDatetime.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-97358-RemovedEvalintFromTCATypeDatetime.html - // => Directly solved in `Configuration/TCA/tx_wvdeepltranslate_glossary.php as version check. - - // removed cruser_id [3] - unset($GLOBALS['TCA']['tx_wvdeepltranslate_glossary']['ctrl']['cruser_id']); - } -})(); diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossary.php b/Configuration/TCA/tx_wvdeepltranslate_glossary.php index bc45e361..6626b8fd 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossary.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossary.php @@ -10,7 +10,6 @@ 'default_sortby' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', - 'cruser_id' => 'cruser_id', 'delete' => 'deleted', 'hideTable' => true, 'versioningWS' => false, diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php index 746b98b7..ed26e1c2 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php @@ -10,7 +10,6 @@ 'default_sortby' => 'term ASC', 'tstamp' => 'tstamp', 'crdate' => 'crdate', - 'cruser_id' => 'cruser_id', 'delete' => 'deleted', 'hideTable' => false, 'versioningWS' => false, From 52b778851609a638269bf11bb09ac0aa9fca4dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 17:56:16 +0100 Subject: [PATCH 08/16] [TASK] Align TCA configuration for required column option TYPO3 12.0 deprecated the old way to define a column as required as part of the `eval` [1] and introduced a new option as replacement [2]. Until now this has been handled within the corresponding TCA Override file to keep support for TYPO3 v11 next to TYPO3 v12. This change removes the override and uses the new option in the TCA file directly. [1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97035-RequiredOptionInEvalKeyword.html [2] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97035-UtilizeRequiredDirectlyInTCAFieldConfiguration.html --- .../tx_wvdeepltranslate_glossaryentry.php | 29 ------------------- .../TCA/tx_wvdeepltranslate_glossaryentry.php | 15 ++++------ 2 files changed, 5 insertions(+), 39 deletions(-) delete mode 100644 Configuration/TCA/Overrides/tx_wvdeepltranslate_glossaryentry.php diff --git a/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossaryentry.php b/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossaryentry.php deleted file mode 100644 index b324c563..00000000 --- a/Configuration/TCA/Overrides/tx_wvdeepltranslate_glossaryentry.php +++ /dev/null @@ -1,29 +0,0 @@ -getMajorVersion() >= 12) { - // Adjust TCA configuration to be TYPO3 v12 compatible avoiding TCA automigration. - // 1. https://review.typo3.org/c/Packages/TYPO3.CMS/+/77626 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Deprecation-99739-IndexedArrayKeysForTCAItems.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Feature-99739-AssociativeArrayKeysForTCAItems.html - // => Directly solved in `Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php as version check. - // 2. https://review.typo3.org/c/Packages/TYPO3.CMS/+/73709 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97035-RequiredOptionInEvalKeyword.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97035-UtilizeRequiredDirectlyInTCAFieldConfiguration.html - // 3. https://review.typo3.org/c/Packages/TYPO3.CMS/+/75123 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98024-TCA-option-cruserid-removed.html - // 4. https://review.typo3.org/c/Packages/TYPO3.CMS/+/74027 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97232-NewTCATypeDatetime.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-97358-RemovedEvalintFromTCATypeDatetime.html - // => not needed for this table (yet) - - // required eval -> flag [2] - $GLOBALS['TCA']['tx_wvdeepltranslate_glossaryentry']['columns']['term']['config']['required'] = true; - unset($GLOBALS['TCA']['tx_wvdeepltranslate_glossaryentry']['columns']['term']['config']['eval']); - - // removed cruser_id [3] - unset($GLOBALS['TCA']['tx_wvdeepltranslate_glossaryentry']['ctrl']['cruser_id']); - } -})(); diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php index ed26e1c2..eccea83d 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php @@ -83,16 +83,11 @@ 'term' => [ 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:entry.source', 'l10n_mode' => '', - 'config' => (new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 - ? [ - 'type' => 'input', - 'required' => true, - 'eval' => 'trim', - ] - : [ - 'type' => 'input', - 'eval' => 'trim,reqiured', - ], + 'config' => [ + 'type' => 'input', + 'required' => true, + 'eval' => 'trim', + ], ], ], ]; From 0853f4211e78df659d1bc03f9d8dc73ddc741f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 18:02:54 +0100 Subject: [PATCH 09/16] [TASK] Remove dual TCA option for DateTime columns With TYPO3 v12 a new TCA type=datetime has been introduced, which has been handled conditional for TYPO3 v11 and v12. [1][2] This change removes the TYPO3 v11 conditional handling of these configurations. [1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97232-NewTCATypeDatetime.html [2] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-97358-RemovedEvalintFromTCATypeDatetime.html --- Configuration/TCA/Overrides/pages.php | 22 ++----------------- .../TCA/tx_wvdeepltranslate_glossary.php | 20 +++++------------ 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index de161092..1deb4957 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -58,30 +58,12 @@ 'displayCond' => 'FIELD:sys_language_uid:>:0', 'label' => $ll('pages.tx_wvdeepltranslate_translated_time'), 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', - 'eval' => 'datetime', + 'type' => 'datetime', + 'format' => 'datetime', 'readOnly' => true, 'default' => 0, ], ]; - if ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12) { - // 4. https://review.typo3.org/c/Packages/TYPO3.CMS/+/74027 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97232-NewTCATypeDatetime.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-97358-RemovedEvalintFromTCATypeDatetime.html - $columns['tx_wvdeepltranslate_translated_time'] = [ - 'exclude' => 0, - 'l10n_display' => 'hideDiff', - 'displayCond' => 'FIELD:sys_language_uid:>:0', - 'label' => $ll('pages.tx_wvdeepltranslate_translated_time'), - 'config' => [ - 'type' => 'datetime', - 'format' => 'datetime', - 'readOnly' => true, - 'default' => 0, - ], - ]; - } ExtensionManagementUtility::addTCAcolumns('pages', $columns); diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossary.php b/Configuration/TCA/tx_wvdeepltranslate_glossary.php index 6626b8fd..5a072fb7 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossary.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossary.php @@ -50,21 +50,11 @@ ], 'glossary_lastsync' => [ 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:glossary.glossary_lastsync', - // 4. https://review.typo3.org/c/Packages/TYPO3.CMS/+/74027 - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Feature-97232-NewTCATypeDatetime.html - // https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-97358-RemovedEvalintFromTCATypeDatetime.html - 'config' => (new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 - ? [ - 'type' => 'datetime', - 'format' => 'datetime', - 'readOnly' => true, - ] - : [ - 'type' => 'input', - 'renderType' => 'inputDateTime', - 'eval' => 'datetime', - 'readOnly' => true, - ], + 'config' => [ + 'type' => 'datetime', + 'format' => 'datetime', + 'readOnly' => true, + ], ], 'glossary_ready' => [ 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:glossary.glossary_ready', From 0e7efc134dd9466677f8b6a74ff8a0da724c5279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 18:21:45 +0100 Subject: [PATCH 10/16] [TASK] Use accociative array keys for TCA items TYPO3 v12 changed some TCA definitions. Basically, these are covered for now by the provided TCA auto migration. That triggers `E_USER_DEPREACTED` errors which will fail in tests. TCA automigration and the `E_USER_DEPRECATED` notice has been mitigated with some version based switches within the TCA configuration to avoid failing tests. This change removes the version based configuration in favour of TYPO3 v12 only configuration. [1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Deprecation-99739-IndexedArrayKeysForTCAItems.html [2] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.3/Feature-99739-AssociativeArrayKeysForTCAItems.html --- Configuration/TCA/Overrides/pages.php | 23 +++++++------------ .../TCA/tx_wvdeepltranslate_glossaryentry.php | 8 +++---- Resources/Private/Language/de.locallang.xlf | 4 ++++ Resources/Private/Language/fr.locallang.xlf | 4 ++++ Resources/Private/Language/locallang.xlf | 3 +++ 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php index 1deb4957..f636bf35 100644 --- a/Configuration/TCA/Overrides/pages.php +++ b/Configuration/TCA/Overrides/pages.php @@ -5,17 +5,10 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; (static function (): void { - $ll = function (string $languageKey) { - return sprintf( - 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:%s', - $languageKey - ); - }; - $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [ - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'label' : 0) => 'DeepL Glossary', - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'value' : 1) => 'glossary', - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'icon' : 2) => 'apps-pagetree-folder-contains-glossary', + 'label' => 'DeepL Glossary', + 'value' => 'glossary', + 'icon' => 'apps-pagetree-folder-contains-glossary', ]; $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes']['contains-glossary'] = 'apps-pagetree-folder-contains-glossary'; @@ -25,18 +18,18 @@ 'exclude' => 0, 'l10n_display' => 'hideDiff', 'displayCond' => 'FIELD:sys_language_uid:>:0', - 'label' => $ll('pages.tx_wvdeepltranslate_content_not_checked'), + 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:pages.tx_wvdeepltranslate_content_not_checked', 'config' => [ 'type' => 'check', 'items' => [ [ - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'label' : 0) => $ll('traslated_with_deepl'), + 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:translated_with_deepl', ], ], ], ], 'glossary_information' => [ - 'label' => $ll('pages.glossary_information'), + 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:pages.glossary_information', 'displayCond' => [ 'AND' => [ 'FIELD:doktype:=:254', @@ -56,7 +49,7 @@ 'exclude' => 0, 'l10n_display' => 'hideDiff', 'displayCond' => 'FIELD:sys_language_uid:>:0', - 'label' => $ll('pages.tx_wvdeepltranslate_translated_time'), + 'label' => 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:pages.tx_wvdeepltranslate_translated_time', 'config' => [ 'type' => 'datetime', 'format' => 'datetime', @@ -79,7 +72,7 @@ ExtensionManagementUtility::addToAllTCAtypes( 'pages', - sprintf('--div--;%s,--palette--;;deepl_translate;', $ll('pages.deepl.tab.label')), + sprintf('--div--;%s,--palette--;;deepl_translate;', 'LLL:EXT:deepltranslate_core/Resources/Private/Language/locallang.xlf:pages.deepl.tab.label'), '', 'after:language' ); diff --git a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php index eccea83d..c2987955 100644 --- a/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php +++ b/Configuration/TCA/tx_wvdeepltranslate_glossaryentry.php @@ -43,8 +43,8 @@ 'renderType' => 'checkboxToggle', 'items' => [ [ - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'label' : 0) => '', - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'value' : 1) => '', + 'label' => '', + 'value' => '', 'invertStateDisplay' => true, ], ], @@ -58,8 +58,8 @@ 'renderType' => 'selectSingle', 'items' => [ [ - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'label' : 0) => '', - ((new \TYPO3\CMS\Core\Information\Typo3Version())->getMajorVersion() >= 12 ? 'value' : 1) => 0, + 'label' => '', + 'value' => 0, ], ], 'foreign_table' => 'tx_wvdeepltranslate_glossaryentry', diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index d789fc7a..4674cc4a 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -83,6 +83,10 @@ Translated with DeepL Übersetzt mit DeepL + + Translated with DeepL + Übersetzt mit DeepL + diff --git a/Resources/Private/Language/fr.locallang.xlf b/Resources/Private/Language/fr.locallang.xlf index b31a1491..a2dc8c99 100644 --- a/Resources/Private/Language/fr.locallang.xlf +++ b/Resources/Private/Language/fr.locallang.xlf @@ -46,6 +46,10 @@ Translated with DeepL Traduit avec DeepL + + Translated with DeepL + Traduit avec DeepL + Synchronise Glossary diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 50265ee7..49d888d1 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -72,6 +72,9 @@ Translated with DeepL + + Translated with DeepL + From 058305b380b60fe8fcb4b8a3bf57016e57e902a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 18:26:43 +0100 Subject: [PATCH 11/16] [TASK] Remove obsolete `ExtensionManagementUtility::allowTableOnStandardPages` calls The `ext_tables.php` contains two calls to the deprecated `\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages` method called for no longer existing extension tables. Instead of migrating the calls to TCA Override configuration and creating broken tables, these calls are now removed due to beeing obsolete already since 2.x. --- ext_tables.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext_tables.php b/ext_tables.php index dc9b9089..4b3b4ace 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -19,9 +19,6 @@ } } - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_wvdeepltranslate_domain_model_glossaries'); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_wvdeepltranslate_domain_model_glossariessync'); - /** @var AccessRegistry $accessRegistry */ $accessRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(AccessRegistry::class); $GLOBALS['TYPO3_CONF_VARS']['BE']['customPermOptions']['deepltranslate'] ??= []; From 34efde6e95434afd0b2cc092ab67a151fbbb0eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 18:32:48 +0100 Subject: [PATCH 12/16] [TASK] Use UNIX-timestamp as exception codes in abstract testcase --- Tests/Functional/AbstractDeepLTestCase.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Tests/Functional/AbstractDeepLTestCase.php b/Tests/Functional/AbstractDeepLTestCase.php index 54bf37d9..4043601a 100644 --- a/Tests/Functional/AbstractDeepLTestCase.php +++ b/Tests/Functional/AbstractDeepLTestCase.php @@ -123,11 +123,17 @@ protected function setUp(): void if ($this->isMockServer) { $this->authKey = 'mock_server'; if ($this->serverUrl === false) { - throw new \Exception('DEEPL_SERVER_URL environment variable must be set if using a mock server'); + throw new \RuntimeException( + 'DEEPL_SERVER_URL environment variable must be set if using a mock server', + 1733938285, + ); } } else { if (getenv('DEEPL_AUTH_KEY') === false) { - throw new \Exception('DEEPL_AUTH_KEY environment variable must be set unless using a mock server'); + throw new \RuntimeException( + 'DEEPL_AUTH_KEY environment variable must be set unless using a mock server', + 1733938290, + ); } $this->authKey = getenv('DEEPL_AUTH_KEY'); } From a09b597615b8bd5eb5e5e6bdbdc8c41954d58438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 18:55:26 +0100 Subject: [PATCH 13/16] [TASK] Add some method return type declarations This change adds some obvoius method return type declarations. --- Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php | 2 +- Classes/Hooks/TCEmainHook.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php b/Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php index 4c3b30f4..fb453a04 100644 --- a/Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php +++ b/Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php @@ -17,7 +17,7 @@ public function __construct( $this->deeplService = $deeplService; } - public function getSupportedLanguageForField(array &$configuration) + public function getSupportedLanguageForField(array &$configuration): void { $supportedLanguages = $this->deeplService->getSupportLanguage()['target']; diff --git a/Classes/Hooks/TCEmainHook.php b/Classes/Hooks/TCEmainHook.php index 6cc471eb..0a950652 100644 --- a/Classes/Hooks/TCEmainHook.php +++ b/Classes/Hooks/TCEmainHook.php @@ -19,7 +19,7 @@ class TCEmainHook implements DataHandlerCheckModifyAccessListHookInterface * @param string $table The name of the table to be modified * @param DataHandler $parent The calling parent object */ - public function checkModifyAccessList(&$accessAllowed, $table, DataHandler $parent) + public function checkModifyAccessList(&$accessAllowed, $table, DataHandler $parent): void { if ($table == 'localization') { $accessAllowed = true; From 27f9a09b34c2266da22074fe8a109674a960c9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 19:01:40 +0100 Subject: [PATCH 14/16] [TASK] Avoid deprecated `TypoScriptFrontendController->doWorkspacePreview()` With TYPO3 v12 some `TypoScriptFrontendController` methods has been deprecated in favour of the context class [1]. This change replaces the method call following the recommended migration path noted in the TYPO3 changelog entry [1]. [1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97531-ContextRelatedMethodsWithinTSFE.html --- Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php b/Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php index 52741911..90b73233 100644 --- a/Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php +++ b/Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php @@ -21,7 +21,7 @@ public function renderDeeplPreviewFlag(array $params): void && $controller->getContext()->getPropertyFromAspect('frontend.preview', 'isPreview'); if ( !$isInPreviewMode - || $controller->doWorkspacePreview() + || $controller->getContext()->getPropertyFromAspect('workspace', 'isOffline', false) || ($controller->config['config']['disablePreviewNotification'] ?? false) || ( isset($controller->page['tx_wvdeepltranslate_translated_time']) From 3663ad47fd323f8b5f6c3e116f9b4e03f3fab1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 19:20:30 +0100 Subject: [PATCH 15/16] [TASK] Migrate deprecated flash message constants TYPO3 v12 deprecated the use of the flash message constants (integer value) as message severitys in favour on a new native enum class [1]. This change replaces usages of these constants with the enum as no TYPO3 v11 support is needed anymore and prepares for adding TYPO3 v13 support. Following `UsageService` methods are now marked as internal to make it clear: * determineSeverity() * determineSeverityForSystemInformation() [1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Deprecation-97787-SeveritiesOfFlashMessagesAndReportsDeprecated.html --- .../Glossary/UpdatedGlossaryEntryTermHook.php | 4 +-- Classes/Hooks/UsageProcessAfterFinishHook.php | 3 ++- Classes/Service/UsageService.php | 25 +++++++++++++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php b/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php index fd87551c..b4592cb3 100644 --- a/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php +++ b/Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php @@ -7,9 +7,9 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Exception; use TYPO3\CMS\Core\DataHandling\DataHandler; -use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use WebVision\Deepltranslate\Core\Domain\Repository\GlossaryEntryRepository; @@ -69,7 +69,7 @@ public function processDatamap_afterDatabaseOperations( 'glossary.not-sync.title', 'DeepltranslateCore' ), - AbstractMessage::INFO, + ContextualFeedbackSeverity::INFO, true ); diff --git a/Classes/Hooks/UsageProcessAfterFinishHook.php b/Classes/Hooks/UsageProcessAfterFinishHook.php index f3b304d5..ba0d2710 100644 --- a/Classes/Hooks/UsageProcessAfterFinishHook.php +++ b/Classes/Hooks/UsageProcessAfterFinishHook.php @@ -9,6 +9,7 @@ use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; use WebVision\Deepltranslate\Core\Service\UsageService; @@ -48,7 +49,7 @@ public function processCmdmap_afterFinish(DataHandler $dataHandler): void $severity = $this->usageService->determineSeverity($usage->character->count, $usage->character->limit); // Reduce noise - Don't bother editors with low quota usage messages - if ($severity === FlashMessage::NOTICE) { + if ($severity === ContextualFeedbackSeverity::NOTICE) { return; } diff --git a/Classes/Service/UsageService.php b/Classes/Service/UsageService.php index 4100a072..0bd4311e 100644 --- a/Classes/Service/UsageService.php +++ b/Classes/Service/UsageService.php @@ -7,8 +7,10 @@ use DeepL\Usage; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use WebVision\Deepltranslate\Core\ClientInterface; +use WebVision\Deepltranslate\Core\Event\Listener\UsageToolBarEventListener; +use WebVision\Deepltranslate\Core\Hooks\UsageProcessAfterFinishHook; final class UsageService implements UsageServiceInterface { @@ -73,25 +75,34 @@ public function formatNumber(int $number) /** * Calculate the message severity based on the quota usage rate * + * Only to be used in {@see UsageProcessAfterFinishHook::processCmdmap_afterFinish()}. + * * @param int $characterCount Already translated characters in the current billing period * @param int $characterLimit Total character limit in the current billing period - * @return int Severity level + * @return ContextualFeedbackSeverity Severity level + * + * @internal to be used only within `web-vision/deepltranslate-core`, not part of public API. */ - public function determineSeverity(int $characterCount, int $characterLimit): int + public function determineSeverity(int $characterCount, int $characterLimit): ContextualFeedbackSeverity { $quotaUtilization = ($characterCount / $characterLimit) * 100; if ($quotaUtilization >= 100) { - return FlashMessage::ERROR; + return ContextualFeedbackSeverity::ERROR; } if ($quotaUtilization >= 98) { - return FlashMessage::WARNING; + return ContextualFeedbackSeverity::WARNING; } if ($quotaUtilization >= 90) { - return FlashMessage::INFO; + return ContextualFeedbackSeverity::INFO; } - return FlashMessage::NOTICE; + return ContextualFeedbackSeverity::NOTICE; } + /** + * Used only in {@see UsageToolBarEventListener::__invoke()}. + * + * @internal to be used only within `web-vision/deepltranslate-core`, not part of public API. + */ public function determineSeverityForSystemInformation(int $characterCount, int $characterLimit): string { $quotaUtilization = ($characterCount / $characterLimit) * 100; From 4f6b41accdc91835b8df4d69a86c46916752608b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 11 Dec 2024 19:26:29 +0100 Subject: [PATCH 16/16] [TASK] Use PHPUnit attributes instead of annotations This change modifies the tests to use the php attributes provided by PHPUnit instead of the old php doc-block annotations. Used command(s): ```bash Build/Scripts/runTests.sh -t 12 -p 8.1 -s phpstanGenerateBaseline ``` --- Build/phpstan/Core12/phpstan-baseline.neon | 10 ----- Tests/Functional/AbstractDeepLTestCase.php | 17 ++++--- Tests/Functional/ClientTest.php | 42 ++++++------------ .../Fixtures/Traits/SiteBasedTestTrait.php | 12 ++--- ...nfigSupportedLanguageItemsProcFuncTest.php | 10 ++--- .../Form/User/HasFormalitySupportTest.php | 22 +++------- Tests/Functional/Hooks/ButtonBarHookTest.php | 13 ++---- Tests/Functional/Hooks/TranslateHookTest.php | 19 +++----- .../Regression/GlossaryRegressionTest.php | 5 +-- .../Functional/Services/DeeplServiceTest.php | 44 ++++++------------- .../Services/LanguageServiceTest.php | 21 +++------ .../Functional/Services/UsageServiceTest.php | 21 +++------ .../Updates/FormalityUpgradeWizardTest.php | 5 +-- .../ExtensionActiveViewHelperTest.php | 9 ++-- Tests/Unit/Access/AccessRegistryTest.php | 14 +++--- .../Access/AllowedGlossarySyncAccessTest.php | 21 +++------ .../Access/AllowedTranslateAccessTest.php | 21 +++------ Tests/Unit/ClientTest.php | 29 ++++-------- 18 files changed, 114 insertions(+), 221 deletions(-) diff --git a/Build/phpstan/Core12/phpstan-baseline.neon b/Build/phpstan/Core12/phpstan-baseline.neon index 8d95d08f..1b117626 100644 --- a/Build/phpstan/Core12/phpstan-baseline.neon +++ b/Build/phpstan/Core12/phpstan-baseline.neon @@ -60,11 +60,6 @@ parameters: count: 1 path: ../../../Classes/Event/Listener/GlossarySyncButtonProvider.php - - - message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Form\\\\Item\\\\SiteConfigSupportedLanguageItemsProcFunc\\:\\:getSupportedLanguageForField\\(\\) has no return type specified\\.$#" - count: 1 - path: ../../../Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php - - message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Form\\\\Item\\\\SiteConfigSupportedLanguageItemsProcFunc\\:\\:getSupportedLanguageForField\\(\\) has parameter \\$configuration with no value type specified in iterable type array\\.$#" count: 1 @@ -95,11 +90,6 @@ parameters: count: 1 path: ../../../Classes/Hooks/Glossary/UpdatedGlossaryEntryTermHook.php - - - message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Hooks\\\\TCEmainHook\\:\\:checkModifyAccessList\\(\\) has no return type specified\\.$#" - count: 1 - path: ../../../Classes/Hooks/TCEmainHook.php - - message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Override\\\\Core12\\\\DatabaseRecordList\\:\\:makeLocalizationPanel\\(\\) has parameter \\$translations with no value type specified in iterable type array\\.$#" count: 1 diff --git a/Tests/Functional/AbstractDeepLTestCase.php b/Tests/Functional/AbstractDeepLTestCase.php index 4043601a..b7247fa6 100644 --- a/Tests/Functional/AbstractDeepLTestCase.php +++ b/Tests/Functional/AbstractDeepLTestCase.php @@ -4,6 +4,9 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional; +use RuntimeException; +use Closure; +use Exception; use DeepL\Translator; use DeepL\TranslatorOptions; use phpmock\phpunit\PHPMock; @@ -123,14 +126,14 @@ protected function setUp(): void if ($this->isMockServer) { $this->authKey = 'mock_server'; if ($this->serverUrl === false) { - throw new \RuntimeException( + throw new RuntimeException( 'DEEPL_SERVER_URL environment variable must be set if using a mock server', 1733938285, ); } } else { if (getenv('DEEPL_AUTH_KEY') === false) { - throw new \RuntimeException( + throw new RuntimeException( 'DEEPL_AUTH_KEY environment variable must be set unless using a mock server', 1733938290, ); @@ -207,7 +210,7 @@ protected function instantiateMockServerClient(array $options = []): void // use closure to set private option for translation $translator = new Translator(self::getInstanceIdentifier(), $mergedOptions); - \Closure::bind( + Closure::bind( function (Translator $translator) { $this->translator = $translator; }, @@ -262,11 +265,11 @@ public function tempFiles(): array return [$tempDir, $exampleDocument, $exampleLargeDocument, $outputDocumentPath]; } - public function assertExceptionContains(string $needle, callable $function): \Exception + public function assertExceptionContains(string $needle, callable $function): Exception { try { $function(); - } catch (\Exception $exception) { + } catch (Exception $exception) { static::assertStringContainsString($needle, $exception->getMessage()); return $exception; } @@ -276,11 +279,11 @@ public function assertExceptionContains(string $needle, callable $function): \Ex /** * @param class-string $class */ - public function assertExceptionClass(string $class, callable $function): \Exception + public function assertExceptionClass(string $class, callable $function): Exception { try { $function(); - } catch (\Exception $exception) { + } catch (Exception $exception) { static::assertEquals($class, get_class($exception)); return $exception; } diff --git a/Tests/Functional/ClientTest.php b/Tests/Functional/ClientTest.php index 84bd77ff..f73bdc2f 100644 --- a/Tests/Functional/ClientTest.php +++ b/Tests/Functional/ClientTest.php @@ -4,6 +4,10 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional; +use PHPUnit\Framework\Attributes\CoversClass; +use WebVision\Deepltranslate\Core\Client; +use PHPUnit\Framework\Attributes\Test; +use DateTime; use DeepL\GlossaryEntries; use DeepL\GlossaryInfo; use DeepL\GlossaryLanguagePair; @@ -12,9 +16,7 @@ use Helmich\JsonAssert\JsonAssertions; use WebVision\Deepltranslate\Core\ClientInterface; -/** - * @covers \WebVision\Deepltranslate\Core\Client - */ +#[CoversClass(Client::class)] final class ClientTest extends AbstractDeepLTestCase { use JsonAssertions; @@ -28,9 +30,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @test - */ + #[Test] public function checkResponseFromTranslateContent(): void { $translateContent = self::EXAMPLE_TEXT['en']; @@ -45,9 +45,7 @@ public function checkResponseFromTranslateContent(): void static::assertSame(self::EXAMPLE_TEXT['de'], $response->text); } - /** - * @test - */ + #[Test] public function checkResponseFromSupportedTargetLanguage(): void { $client = $this->get(ClientInterface::class); @@ -57,9 +55,7 @@ public function checkResponseFromSupportedTargetLanguage(): void static::assertContainsOnlyInstancesOf(Language::class, $response); } - /** - * @test - */ + #[Test] public function checkResponseFromGlossaryLanguagePairs(): void { $client = $this->get(ClientInterface::class); @@ -69,9 +65,7 @@ public function checkResponseFromGlossaryLanguagePairs(): void static::assertContainsOnlyInstancesOf(GlossaryLanguagePair::class, $response); } - /** - * @test - */ + #[Test] public function checkResponseFromCreateGlossary(): void { $client = $this->get(ClientInterface::class); @@ -90,12 +84,10 @@ public function checkResponseFromCreateGlossary(): void static::assertInstanceOf(GlossaryInfo::class, $response); static::assertSame(1, $response->entryCount); static::assertIsString($response->glossaryId); - static::assertInstanceOf(\DateTime::class, $response->creationTime); + static::assertInstanceOf(DateTime::class, $response->creationTime); } - /** - * @test - */ + #[Test] public function checkResponseGetAllGlossaries(): void { $client = $this->get(ClientInterface::class); @@ -105,9 +97,7 @@ public function checkResponseGetAllGlossaries(): void static::assertContainsOnlyInstancesOf(GlossaryInfo::class, $response); } - /** - * @test - */ + #[Test] public function checkResponseFromGetGlossary(): void { $client = $this->get(ClientInterface::class); @@ -130,9 +120,7 @@ public function checkResponseFromGetGlossary(): void static::assertSame(1, $response->entryCount); } - /** - * @test - */ + #[Test] public function checkGlossaryDeletedNotCatchable(): void { $client = $this->get(ClientInterface::class); @@ -155,9 +143,7 @@ public function checkGlossaryDeletedNotCatchable(): void static::assertNull($client->getGlossary($glossaryId)); } - /** - * @test - */ + #[Test] public function checkResponseFromGetGlossaryEntries(): void { $client = $this->get(ClientInterface::class); diff --git a/Tests/Functional/Fixtures/Traits/SiteBasedTestTrait.php b/Tests/Functional/Fixtures/Traits/SiteBasedTestTrait.php index 4d3c5eea..55b541de 100644 --- a/Tests/Functional/Fixtures/Traits/SiteBasedTestTrait.php +++ b/Tests/Functional/Fixtures/Traits/SiteBasedTestTrait.php @@ -2,6 +2,8 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Fixtures\Traits; +use Exception; +use LogicException; use Psr\EventDispatcher\EventDispatcherInterface; use TYPO3\CMS\Core\Configuration\SiteConfiguration; use TYPO3\CMS\Core\Information\Typo3Version; @@ -58,7 +60,7 @@ protected function writeSiteConfiguration( // ensure no previous site configuration influences the test GeneralUtility::rmdir($this->instancePath . '/typo3conf/sites/' . $identifier, true); $siteConfiguration->write($identifier, $configuration); - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->markTestSkipped($exception->getMessage()); } } @@ -72,7 +74,7 @@ protected function mergeSiteConfiguration( $configuration = array_merge($configuration, $overrides); try { $siteConfiguration->write($identifier, $configuration); - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->markTestSkipped($exception->getMessage()); } } @@ -206,7 +208,7 @@ protected function buildErrorHandlingConfiguration( 'errorPhpClassFQCN' => PhpError::class, ]; } else { - throw new \LogicException( + throw new LogicException( sprintf('Invalid handler "%s"', $handler), 1533894782 ); @@ -229,7 +231,7 @@ static function (int $code) use ($baseConfiguration) { protected function resolveLanguagePreset(string $identifier) { if (!isset(static::LANGUAGE_PRESETS[$identifier])) { - throw new \LogicException( + throw new LogicException( sprintf('Undefined preset identifier "%s"', $identifier), 1533893665 ); @@ -262,7 +264,7 @@ protected function applyInstructions(InternalRequest $request, AbstractInstructi protected function mergeInstruction(AbstractInstruction $current, AbstractInstruction $other): AbstractInstruction { if (get_class($current) !== get_class($other)) { - throw new \LogicException('Cannot merge different instruction types', 1565863174); + throw new LogicException('Cannot merge different instruction types', 1565863174); } if ($current instanceof TypoScriptInstruction) { diff --git a/Tests/Functional/Form/Items/SiteConfigSupportedLanguageItemsProcFuncTest.php b/Tests/Functional/Form/Items/SiteConfigSupportedLanguageItemsProcFuncTest.php index b4217501..6b38b6e6 100644 --- a/Tests/Functional/Form/Items/SiteConfigSupportedLanguageItemsProcFuncTest.php +++ b/Tests/Functional/Form/Items/SiteConfigSupportedLanguageItemsProcFuncTest.php @@ -4,13 +4,13 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Form\Items; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Utility\GeneralUtility; use WebVision\Deepltranslate\Core\Form\Item\SiteConfigSupportedLanguageItemsProcFunc; use WebVision\Deepltranslate\Core\Tests\Functional\AbstractDeepLTestCase; -/** - * @covers \WebVision\Deepltranslate\Core\Form\Item\SiteConfigSupportedLanguageItemsProcFunc - */ +#[CoversClass(SiteConfigSupportedLanguageItemsProcFunc::class)] final class SiteConfigSupportedLanguageItemsProcFuncTest extends AbstractDeepLTestCase { protected function setUp(): void @@ -23,9 +23,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @test - */ + #[Test] public function getSupportedLanguageFormFields(): void { $func = GeneralUtility::makeInstance(SiteConfigSupportedLanguageItemsProcFunc::class); diff --git a/Tests/Functional/Form/User/HasFormalitySupportTest.php b/Tests/Functional/Form/User/HasFormalitySupportTest.php index 2001b589..40694bd7 100644 --- a/Tests/Functional/Form/User/HasFormalitySupportTest.php +++ b/Tests/Functional/Form/User/HasFormalitySupportTest.php @@ -4,13 +4,13 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Form\User; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Backend\Form\FormDataProvider\EvaluateDisplayConditions; use WebVision\Deepltranslate\Core\Form\User\HasFormalitySupport; use WebVision\Deepltranslate\Core\Tests\Functional\AbstractDeepLTestCase; -/** - * @covers \WebVision\Deepltranslate\Core\Form\User\HasFormalitySupport - */ +#[CoversClass(HasFormalitySupport::class)] class HasFormalitySupportTest extends AbstractDeepLTestCase { protected function setUp(): void @@ -23,9 +23,7 @@ protected function setUp(): void parent::setUp(); } - /** - * @test - */ + #[Test] public function hasFormalitySupportIsSupported(): void { /** @var HasFormalitySupport $subject */ @@ -43,9 +41,7 @@ public function hasFormalitySupportIsSupported(): void static::assertTrue($isFormalitySupported); } - /** - * @test - */ + #[Test] public function hasFormalitySupportIsNotSupported(): void { /** @var HasFormalitySupport $subject */ @@ -63,9 +59,7 @@ public function hasFormalitySupportIsNotSupported(): void static::assertFalse($isFormalitySupported); } - /** - * @test - */ + #[Test] public function formalityIsNotSupportedWhenRecordNotExist(): void { /** @var HasFormalitySupport $subject */ @@ -77,9 +71,7 @@ public function formalityIsNotSupportedWhenRecordNotExist(): void static::assertFalse($isFormalitySupported); } - /** - * @test - */ + #[Test] public function formalityIsNotSupportedWhenDeeplTargetLanguageNotExistOrEmpty(): void { /** @var HasFormalitySupport $subject */ diff --git a/Tests/Functional/Hooks/ButtonBarHookTest.php b/Tests/Functional/Hooks/ButtonBarHookTest.php index f53bff0e..d321ff7a 100644 --- a/Tests/Functional/Hooks/ButtonBarHookTest.php +++ b/Tests/Functional/Hooks/ButtonBarHookTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Hooks; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; @@ -33,9 +34,7 @@ public function setUp(): void } - /** - * @test - */ + #[Test] public function showGlossarySynchronizationButton(): void { // User with Access @@ -54,9 +53,7 @@ public function showGlossarySynchronizationButton(): void static::assertInstanceOf(LinkButton::class, $button); } - /** - * @test - */ + #[Test] public function displayGlossarySynchronizationButtonBecauseNotRightModel(): void { // Backend-Admin User @@ -70,9 +67,7 @@ public function displayGlossarySynchronizationButtonBecauseNotRightModel(): void static::assertFalse(isset($buttons[ButtonBar::BUTTON_POSITION_LEFT][5])); } - /** - * @test - */ + #[Test] public function displayGlossarySynchronizationButtonBecauseNotAllowed(): void { // Backend-Admin User diff --git a/Tests/Functional/Hooks/TranslateHookTest.php b/Tests/Functional/Hooks/TranslateHookTest.php index 85c55f63..8d0e88cb 100644 --- a/Tests/Functional/Hooks/TranslateHookTest.php +++ b/Tests/Functional/Hooks/TranslateHookTest.php @@ -4,6 +4,8 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Hooks; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Core\Bootstrap; use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -18,9 +20,7 @@ use WebVision\Deepltranslate\Core\Tests\Functional\AbstractDeepLTestCase; use WebVision\Deepltranslate\Core\Tests\Functional\Fixtures\Traits\SiteBasedTestTrait; -/** - * @covers \WebVision\Deepltranslate\Core\Hooks\TranslateHook - */ +#[CoversClass(TranslateHook::class)] final class TranslateHookTest extends AbstractDeepLTestCase { use SiteBasedTestTrait; @@ -99,9 +99,7 @@ protected function setUp(): void $processingInstruction->setProcessingInstruction(null, null, true); } - /** - * @test - */ + #[Test] public function contentTranslateWithDeepl(): void { $translateContent = 'proton beam'; @@ -125,9 +123,7 @@ public function contentTranslateWithDeepl(): void static::assertSame($expectedTranslation, $content); } - /** - * @test - */ + #[Test] public function contentNotTranslateWithDeeplWhenLanguageNotSupported(): void { $serverParams = array_replace($_SERVER, ['HTTP_HOST' => 'example.com', 'SCRIPT_NAME' => '/typo3/index.php']); @@ -152,9 +148,7 @@ public function contentNotTranslateWithDeeplWhenLanguageNotSupported(): void static::assertSame('', $content); } - /** - * @test - */ + #[Test] public function translateContentElementsAndUpdatePagesProperties(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/BeUsersTranslateDeeplFlag.csv'); @@ -195,6 +189,7 @@ public function translateContentElementsAndUpdatePagesProperties(): void 1, )->fetchAssociative(); + static::assertIsArray($pageRow); static::assertArrayHasKey('tx_wvdeepltranslate_content_not_checked', $pageRow); static::assertSame(1, (int)$pageRow['tx_wvdeepltranslate_content_not_checked']); static::assertArrayHasKey('tx_wvdeepltranslate_translated_time', $pageRow); diff --git a/Tests/Functional/Regression/GlossaryRegressionTest.php b/Tests/Functional/Regression/GlossaryRegressionTest.php index 10f1361f..95e26e63 100644 --- a/Tests/Functional/Regression/GlossaryRegressionTest.php +++ b/Tests/Functional/Regression/GlossaryRegressionTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Regression; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -72,9 +73,7 @@ protected function setUp(): void ->syncGlossaries(2); } - /** - * @test - */ + #[Test] public function glossaryIsRespectedOnLocalization(): void { $commandMap = [ diff --git a/Tests/Functional/Services/DeeplServiceTest.php b/Tests/Functional/Services/DeeplServiceTest.php index 0f0633aa..a656b053 100644 --- a/Tests/Functional/Services/DeeplServiceTest.php +++ b/Tests/Functional/Services/DeeplServiceTest.php @@ -4,15 +4,15 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Services; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use DeepL\Language; use WebVision\Deepltranslate\Core\Domain\Dto\TranslateContext; use WebVision\Deepltranslate\Core\Service\DeeplService; use WebVision\Deepltranslate\Core\Service\ProcessingInstruction; use WebVision\Deepltranslate\Core\Tests\Functional\AbstractDeepLTestCase; -/** - * @covers \WebVision\Deepltranslate\Core\Service\DeeplService - */ +#[CoversClass(DeeplService::class)] final class DeeplServiceTest extends AbstractDeepLTestCase { protected function setUp(): void @@ -31,9 +31,9 @@ protected function setUp(): void } /** - * @test * @deprecated if the @see DeeplService::translateRequest() function has been removed */ + #[Test] public function translateContentFromDeToEn(): void { /** @var DeeplService $deeplService */ @@ -49,9 +49,9 @@ public function translateContentFromDeToEn(): void } /** - * @test * @deprecated if the @see DeeplService::translateRequest() function has been removed */ + #[Test] public function translateContentFromEnToDe(): void { $translateContent = 'proton beam'; @@ -69,9 +69,9 @@ public function translateContentFromEnToDe(): void } /** - * @test * @deprecated entfällt wenn die Funktion @see DeeplService::translateRequest() entfernt wurde */ + #[Test] public function translateContentWithAutoDetectSourceParam(): void { $translateContent = 'proton beam'; @@ -88,9 +88,7 @@ public function translateContentWithAutoDetectSourceParam(): void static::assertSame($expectedTranslation, $translateContent); } - /** - * @test - */ + #[Test] public function translateContentWithTranslateContextFromDeToEn(): void { /** @var DeeplService $deeplService */ @@ -105,9 +103,7 @@ public function translateContentWithTranslateContextFromDeToEn(): void static::assertSame('proton beam', $translateContent); } - /** - * @test - */ + #[Test] public function translateContentWithTranslateContextFromEnToDe(): void { /** @var DeeplService $deeplService */ @@ -122,9 +118,7 @@ public function translateContentWithTranslateContextFromEnToDe(): void static::assertSame('Protonenstrahl', $translateContent); } - /** - * @test - */ + #[Test] public function translateContentWithTranslateContextWithAutoDetectSourceParam(): void { /** @var DeeplService $deeplService */ @@ -139,9 +133,7 @@ public function translateContentWithTranslateContextWithAutoDetectSourceParam(): static::assertSame('Protonenstrahl', $translateContent); } - /** - * @test - */ + #[Test] public function checkSupportedTargetLanguages(): void { /** @var DeeplService $deeplService */ @@ -157,9 +149,7 @@ public function checkSupportedTargetLanguages(): void static::assertNull($deeplService->detectTargetLanguage('BS')); } - /** - * @test - */ + #[Test] public function checkIsTargetLanguageSupported(): void { /** @var DeeplService $deeplService */ @@ -171,9 +161,7 @@ public function checkIsTargetLanguageSupported(): void static::assertFalse($deeplService->isTargetLanguageSupported('BS')); } - /** - * @test - */ + #[Test] public function checkSupportedSourceLanguages(): void { /** @var DeeplService $deeplService */ @@ -187,9 +175,7 @@ public function checkSupportedSourceLanguages(): void static::assertNull($deeplService->detectSourceLanguage('BS')); } - /** - * @test - */ + #[Test] public function checkIsSourceLanguageSupported(): void { /** @var DeeplService $deeplService */ @@ -198,9 +184,7 @@ public function checkIsSourceLanguageSupported(): void static::assertTrue($deeplService->isSourceLanguageSupported('DE')); } - /** - * @test - */ + #[Test] public function checkHasLanguageFormalitySupport(): void { /** @var DeeplService $deeplService */ diff --git a/Tests/Functional/Services/LanguageServiceTest.php b/Tests/Functional/Services/LanguageServiceTest.php index f2fcdc33..7e7f60db 100644 --- a/Tests/Functional/Services/LanguageServiceTest.php +++ b/Tests/Functional/Services/LanguageServiceTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Services; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Core\Site\SiteFinder; use WebVision\Deepltranslate\Core\Exception\LanguageIsoCodeNotFoundException; use WebVision\Deepltranslate\Core\Exception\LanguageRecordNotFoundException; @@ -106,9 +107,7 @@ protected function setUp(): void $this->setUpFrontendRootPage(3, [], []); } - /** - * @test - */ + #[Test] public function getSourceLanguageInformationIsValid(): void { /** @var LanguageService $languageService */ @@ -127,9 +126,7 @@ public function getSourceLanguageInformationIsValid(): void static::assertSame('EN', $sourceLanguageRecord['language_isocode']); } - /** - * @test - */ + #[Test] public function setAutoDetectOptionForSourceLanguageNotSupported(): void { /** @var LanguageService $languageService */ @@ -143,9 +140,7 @@ public function setAutoDetectOptionForSourceLanguageNotSupported(): void static::assertContains('auto', $sourceLanguageRecord); } - /** - * @test - */ + #[Test] public function getTargetLanguageInformationIsValid(): void { /** @var LanguageService $languageService */ @@ -164,9 +159,7 @@ public function getTargetLanguageInformationIsValid(): void static::assertSame('DE', $sourceLanguageRecord['language_isocode']); } - /** - * @test - */ + #[Test] public function getTargetLanguageExceptionWhenLanguageNotExist(): void { /** @var LanguageService $languageService */ @@ -180,9 +173,7 @@ public function getTargetLanguageExceptionWhenLanguageNotExist(): void $languageService->getTargetLanguage($siteInformation, 1); } - /** - * @test - */ + #[Test] public function getTargetLanguageExceptionWhenLanguageIsoNotSupported(): void { /** @var LanguageService $languageService */ diff --git a/Tests/Functional/Services/UsageServiceTest.php b/Tests/Functional/Services/UsageServiceTest.php index 4317144b..ec72e9a9 100644 --- a/Tests/Functional/Services/UsageServiceTest.php +++ b/Tests/Functional/Services/UsageServiceTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Services; +use PHPUnit\Framework\Attributes\Test; use DeepL\Usage; use DeepL\UsageDetail; use WebVision\Deepltranslate\Core\Service\DeeplService; @@ -29,9 +30,7 @@ protected function setUp(): void $processingInstruction->setProcessingInstruction(null, null, true); } - /** - * @test - */ + #[Test] public function classLoadable(): void { $usageService = $this->get(UsageService::class); @@ -39,9 +38,7 @@ public function classLoadable(): void static::assertInstanceOf(UsageService::class, $usageService); } - /** - * @test - */ + #[Test] public function usageReturnsValue(): void { /** @var UsageService $usageService */ @@ -52,9 +49,7 @@ public function usageReturnsValue(): void static::assertInstanceOf(Usage::class, $usage); } - /** - * @test - */ + #[Test] public function limitExceedReturnsFalse(): void { /** @var UsageService $usageService */ @@ -63,9 +58,7 @@ public function limitExceedReturnsFalse(): void static::assertFalse($usageService->checkTranslateLimitWillBeExceeded('')); } - /** - * @test - */ + #[Test] public function limitExceedReturnsTrueIfLimitIsReached(): void { $translateContent = 'proton beam'; @@ -87,9 +80,7 @@ public function limitExceedReturnsTrueIfLimitIsReached(): void static::assertTrue($isLimitExceeded); } - /** - * @test - */ + #[Test] public function checkHTMLMarkupsIsNotPartOfLimit(): void { $translateContent = 'proton beam'; diff --git a/Tests/Functional/Updates/FormalityUpgradeWizardTest.php b/Tests/Functional/Updates/FormalityUpgradeWizardTest.php index fa363002..1d78b082 100644 --- a/Tests/Functional/Updates/FormalityUpgradeWizardTest.php +++ b/Tests/Functional/Updates/FormalityUpgradeWizardTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\Updates; +use PHPUnit\Framework\Attributes\Test; use Symfony\Component\Console\Output\OutputInterface; use TYPO3\CMS\Core\Configuration\SiteConfiguration; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -92,9 +93,7 @@ protected function setUp(): void $this->setUpFrontendRootPage(1, [], []); } - /** - * @test - */ + #[Test] public function executeSuccessMigrationProcess(): void { $wizard = GeneralUtility::makeInstance(FormalityUpgradeWizard::class); diff --git a/Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php b/Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php index eceefa82..7d72fd73 100644 --- a/Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php +++ b/Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php @@ -4,6 +4,9 @@ namespace WebVision\Deepltranslate\Core\Tests\Functional\ViewHelpers; +use Generator; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use TYPO3\CMS\Fluid\View\TemplateView; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; use TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface; @@ -35,7 +38,7 @@ public static function tearDownAfterClass(): void rmdir(self::$cachePath); } - public static function renderDataProvider(): \Generator + public static function renderDataProvider(): Generator { yield 'extension name empty, await else' => [ '', @@ -62,10 +65,10 @@ public static function renderDataProvider(): \Generator } /** - * @test - * @dataProvider renderDataProvider * @param array $variables */ + #[DataProvider('renderDataProvider')] + #[Test] public function render(string $template, array $variables, string $expected): void { $view = new TemplateView(); diff --git a/Tests/Unit/Access/AccessRegistryTest.php b/Tests/Unit/Access/AccessRegistryTest.php index 411e2491..935ad61c 100644 --- a/Tests/Unit/Access/AccessRegistryTest.php +++ b/Tests/Unit/Access/AccessRegistryTest.php @@ -4,18 +4,16 @@ namespace WebVision\Deepltranslate\Core\Tests\Unit\Access; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Test; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; use WebVision\Deepltranslate\Core\Access\AccessItemInterface; use WebVision\Deepltranslate\Core\Access\AccessRegistry; -/** - * @covers \WebVision\Deepltranslate\Core\Access\AccessRegistry.php - */ +#[CoversClass(AccessRegistry::class)] class AccessRegistryTest extends UnitTestCase { - /** - * @test - */ + #[Test] public function registerAccessStoresTheAccessCorrectly(): void { $accessRegistry = new AccessRegistry(); @@ -31,9 +29,7 @@ public function registerAccessStoresTheAccessCorrectly(): void static::assertSame($accessObject, $object); } - /** - * @test - */ + #[Test] public function getAccessReturnsNullForNonExistentIdentifier(): void { $accessRegistry = new AccessRegistry(); diff --git a/Tests/Unit/Access/AllowedGlossarySyncAccessTest.php b/Tests/Unit/Access/AllowedGlossarySyncAccessTest.php index 81b64293..037152be 100644 --- a/Tests/Unit/Access/AllowedGlossarySyncAccessTest.php +++ b/Tests/Unit/Access/AllowedGlossarySyncAccessTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Unit\Access; +use PHPUnit\Framework\Attributes\Test; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; use WebVision\Deepltranslate\Core\Access\AccessItemInterface; use WebVision\Deepltranslate\Core\Access\AllowedGlossarySyncAccess; @@ -17,41 +18,31 @@ protected function setUp(): void $this->accessInstance = new AllowedGlossarySyncAccess(); } - /** - * @test - */ + #[Test] public function hasInterfaceImplementation(): void { static::assertInstanceOf(AccessItemInterface::class, $this->accessInstance); } - /** - * @test - */ + #[Test] public function getIdentifier(): void { static::assertSame('allowedGlossarySync', $this->accessInstance->getIdentifier()); } - /** - * @test - */ + #[Test] public function getTitle(): void { static::assertIsString($this->accessInstance->getTitle()); } - /** - * @test - */ + #[Test] public function getDescription(): void { static::assertIsString($this->accessInstance->getDescription()); } - /** - * @test - */ + #[Test] public function getIconIdentifier(): void { static::assertSame('deepl-logo', $this->accessInstance->getIconIdentifier()); diff --git a/Tests/Unit/Access/AllowedTranslateAccessTest.php b/Tests/Unit/Access/AllowedTranslateAccessTest.php index 090e9938..c0e5e318 100644 --- a/Tests/Unit/Access/AllowedTranslateAccessTest.php +++ b/Tests/Unit/Access/AllowedTranslateAccessTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Unit\Access; +use PHPUnit\Framework\Attributes\Test; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; use WebVision\Deepltranslate\Core\Access\AccessItemInterface; use WebVision\Deepltranslate\Core\Access\AllowedTranslateAccess; @@ -17,41 +18,31 @@ protected function setUp(): void $this->accessInstance = new AllowedTranslateAccess(); } - /** - * @test - */ + #[Test] public function hasInterfaceImplementation(): void { static::assertInstanceOf(AccessItemInterface::class, $this->accessInstance); } - /** - * @test - */ + #[Test] public function getIdentifier(): void { static::assertSame('translateAllowed', $this->accessInstance->getIdentifier()); } - /** - * @test - */ + #[Test] public function getTitle(): void { static::assertIsString($this->accessInstance->getTitle()); } - /** - * @test - */ + #[Test] public function getDescription(): void { static::assertIsString($this->accessInstance->getDescription()); } - /** - * @test - */ + #[Test] public function getIconIdentifier(): void { static::assertSame('deepl-logo', $this->accessInstance->getIconIdentifier()); diff --git a/Tests/Unit/ClientTest.php b/Tests/Unit/ClientTest.php index 0c54ebff..e47cd92c 100644 --- a/Tests/Unit/ClientTest.php +++ b/Tests/Unit/ClientTest.php @@ -4,6 +4,7 @@ namespace WebVision\Deepltranslate\Core\Tests\Unit; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; use WebVision\Deepltranslate\Core\Client; @@ -25,9 +26,7 @@ private function createMockConfigurationWithEmptyApiKey(): MockObject return $mockConfiguration; } - /** - * @test - */ + #[Test] public function throwErrorGetSupportedLanguageByTypeWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -41,9 +40,7 @@ public function throwErrorGetSupportedLanguageByTypeWhenApiKeyNotSet(): void $client->getSupportedLanguageByType(); } - /** - * @test - */ + #[Test] public function throwErrorGetGlossaryLanguagePairsWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -57,9 +54,7 @@ public function throwErrorGetGlossaryLanguagePairsWhenApiKeyNotSet(): void $client->getGlossaryLanguagePairs(); } - /** - * @test - */ + #[Test] public function throwErrorCreateGlossaryEntriesWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -83,9 +78,7 @@ public function throwErrorCreateGlossaryEntriesWhenApiKeyNotSet(): void ); } - /** - * @test - */ + #[Test] public function throwErrorGetGlossaryWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -99,9 +92,7 @@ public function throwErrorGetGlossaryWhenApiKeyNotSet(): void $response = $client->getGlossary('61567955-8db8-493d-aa20-28bbba6fb438'); } - /** - * @test - */ + #[Test] public function throwErrorDeletedGlossaryWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -115,9 +106,7 @@ public function throwErrorDeletedGlossaryWhenApiKeyNotSet(): void $client->deleteGlossary('25d90db6-bcab-4130-ab36-4514dd5d87ec'); } - /** - * @test - */ + #[Test] public function throwErrorGlossaryEntriesWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */ @@ -131,9 +120,7 @@ public function throwErrorGlossaryEntriesWhenApiKeyNotSet(): void $response = $client->getGlossaryEntries('a44703d5-ece7-4230-a67b-1a07153768d6'); } - /** - * @test - */ + #[Test] public function throwErrorTranslationExceptionWhenApiKeyNotSet(): void { /** @var ConfigurationInterface $configurationMock */