From 288155af14e67e85605174abbf19288f08e708b4 Mon Sep 17 00:00:00 2001 From: mabolek Date: Fri, 20 Nov 2020 16:23:52 +0100 Subject: [PATCH 01/37] [TASK] Require at least TYPO3 ^9.5 and ^10.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3f9a6ceb..c5fa7ee1 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "keywords": ["TYPO3 CMS", "Frontend Editing"], "require": { "php": "^7.2", - "typo3/cms-core": "^9.4 || ^10.0" + "typo3/cms-core": "^9.5 || ^10.4" }, "require-dev": { "nimut/testing-framework": "^4.2", From 383d6a832a3df0b5cfe574456dc41b231f34e84c Mon Sep 17 00:00:00 2001 From: mabolek Date: Fri, 20 Nov 2020 16:24:23 +0100 Subject: [PATCH 02/37] [FEATURE] CI with Github Actions --- .github/workflows/ci.yml | 172 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..fc340042 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,172 @@ +on: + push: + branches: + - '*' + - '!master' + +name: CI + +jobs: + php-lint: + name: PHP linter + + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: + - 7.2 + - 7.3 + - 7.4 + + steps: + - name: Configure PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + + - name: Checkout + uses: actions/checkout@v1 + + - name: Run PHP lint + run: | + echo "${{ matrix.exclude-pattern }}" + find *.php Classes/ Configuration/ Tests/ -name '*.php' ${{ matrix.exclude-pattern }} + find *.php Classes/ Configuration/ Tests/ -name '*.php' ${{ matrix.exclude-pattern }} -print0 | xargs -0 -n 1 -P 4 php -l + + typoscript-lint: + name: TypoScript linter + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: "Cache dependencies installed with composer" + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer- + - name: Install Composer dependencies + run: composer install --no-progress + + - name: Run TypoScript lint + run: composer ci:ts:lint + + php-code-sniffer: + name: PHP Code Sniffer + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: "Cache dependencies installed with composer" + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer- + - name: Install Composer dependencies + run: composer install --no-progress + + - name: Run PHP Code Sniffer + run: composer ci:php:sniff + + unit-tests: + name: Unit tests + + runs-on: ubuntu-latest + + strategy: + matrix: + composer-version: + - v1 + - v2 + typo3-version: + - "^9.5" + - "^10.4" + composer-dependencies: + - highest + - lowest + php-version: + - 7.2 + - 7.3 + - 7.4 + include: + - typo3-version: "^9.5" + database-image: mariadb:latest + - typo3-version: "^10.4" + database-image: mariadb:latest + + services: + mysql: + image: ${{ matrix.database-image }} + env: + MYSQL_ALLOW_EMPTY_PASSWORD: false + MYSQL_DATABASE: typo3 + MYSQL_ROOT_PASSWORD: password + MYSQL_USER: user + ports: + - 3306 + + steps: + - name: Configure PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, openssl, pcre, session, SPL, xml, zip, zlib + coverage: none + tools: composer:${{ matrix.composer-version }} + + - name: Checkout + uses: actions/checkout@v1 + + - name: "Cache dependencies installed with composer" + uses: actions/cache@v1 + with: + path: ~/.composer/cache + key: php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: | + php${{ matrix.php-version }}-composer- + + - name: Install TYPO3 Core + env: + TYPO3: ${{ matrix.typo3-version }} + run: | + composer --version + composer require typo3/minimal:"${{ matrix.typo3-version }}" + composer show + + - name: Install lowest dependencies with composer + if: matrix.composer-dependencies == 'lowest' + run: | + composer update --no-ansi --no-interaction --no-progress --no-suggest --prefer-lowest + composer show + + - name: Install highest dependencies with composer + if: matrix.composer-dependencies == 'highest' + run: | + composer update --no-ansi --no-interaction --no-progress --no-suggest + composer show + + - name: Run unit tests + # Environment variable can be removed when TYPO3 v7 support ends + env: + TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/pxa_siteimprove/.Build/public + run: composer ci:tests:unit + + - name: Run functional tests + env: + TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/pxa_siteimprove/.Build/public + typo3DatabaseHost: 127.0.0.1 + typo3DatabasePort: ${{ job.services.mysql.ports['3306'] }} + typo3DatabaseName: typo3 + typo3DatabaseUsername: root + typo3DatabasePassword: password + run: composer ci:tests:functional From 16c23299caa947adafd461746bea29b58cc0ba0e Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:42:57 +0100 Subject: [PATCH 03/37] [TASK] Include typoscript linter and raise codesniffer version --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c5fa7ee1..4c6c0873 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,10 @@ }, "require-dev": { "nimut/testing-framework": "^4.2", - "squizlabs/php_codesniffer": "2.*", + "squizlabs/php_codesniffer": "^3.3", "phpunit/phpunit": "^6.0", - "friendsofphp/php-cs-fixer": "^2.15" + "friendsofphp/php-cs-fixer": "^2.15", + "helmich/typo3-typoscript-lint": "^2.0" }, "conflict": { "typo3/cms-feedit": "*" From 94961a990087b043b9bfc7f5cb11ad73ec90b944 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:46:19 +0100 Subject: [PATCH 04/37] [TASK] Added composer scripts --- composer.json | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4c6c0873..c2b84978 100644 --- a/composer.json +++ b/composer.json @@ -41,9 +41,38 @@ } }, "scripts": { + "ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l", + "ci:php:sniff": "phpcs Classes Tests", + "cs:php:fix": "phpcbf Classes Tests", + "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", + "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", + "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'", + "ci:tests": [ + "@ci:tests:unit", + "@ci:tests:functional" + ], + "ci:dynamic": [ + "@ci:tests" + ], + "ci:static": [ + "@ci:php:lint", + "@ci:php:sniff", + "@ci:ts:lint" + ], + "ci": [ + "@ci:static" + ], + "link-extension": [ + "@php -r 'is_dir($extFolder=__DIR__.\"/.Build/public/typo3conf/ext/\") || mkdir($extFolder, 0777, true);'", + "@php -r 'file_exists($extFolder=__DIR__.\"/.Build/public/typo3conf/ext/frontend_editing\") || symlink(__DIR__,$extFolder);'" + ], + "fix:php-cs": "php-cs-fixer fix", + "fix:php-sniff": "phpcbf Classes Tests", "post-autoload-dump": [ - "mkdir -p .Build/Web/typo3conf/ext/", - "[ -L .Build/Web/typo3conf/ext/frontend_editing ] || ln -snvf ../../../../. .Build/Web/typo3conf/ext/frontend_editing" + "@link-extension" + ], + "docs:generate": [ + "docker run --rm t3docs/render-documentation show-shell-commands > tempfile.sh; echo 'dockrun_t3rd makehtml' >> tempfile.sh; bash tempfile.sh; rm tempfile.sh" ] }, "extra": { From cc3d6bb1af1542069a96c47da2fdf73f1be935b1 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:52:28 +0100 Subject: [PATCH 05/37] [TASK] Renamed .ts to .typoscript --- .../FluidStyledContent9/{setup.ts => setup.typoscript} | 0 Configuration/TypoScript/{setup.ts => setup.typoscript} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Configuration/TypoScript/FluidStyledContent9/{setup.ts => setup.typoscript} (100%) rename Configuration/TypoScript/{setup.ts => setup.typoscript} (99%) diff --git a/Configuration/TypoScript/FluidStyledContent9/setup.ts b/Configuration/TypoScript/FluidStyledContent9/setup.typoscript similarity index 100% rename from Configuration/TypoScript/FluidStyledContent9/setup.ts rename to Configuration/TypoScript/FluidStyledContent9/setup.typoscript diff --git a/Configuration/TypoScript/setup.ts b/Configuration/TypoScript/setup.typoscript similarity index 99% rename from Configuration/TypoScript/setup.ts rename to Configuration/TypoScript/setup.typoscript index b12663d6..2905a2bb 100644 --- a/Configuration/TypoScript/setup.ts +++ b/Configuration/TypoScript/setup.typoscript @@ -32,7 +32,7 @@ tt_content.textpic.stdWrap < lib.fluidContent.stdWrap tt_content.uploads.stdWrap < lib.fluidContent.stdWrap tt_content.mailform.stdWrap < lib.fluidContent.stdWrap -config.tx_extbase{ +config.tx_extbase { objects { TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView } From 130c1da13f5fe009c295ff78a391c9828a20f216 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:52:51 +0100 Subject: [PATCH 06/37] [TASK] Added .editorconfig --- .editorconfig | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d37a2c50 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,52 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# TS/JS-Files +[*.{ts,js}] +indent_size = 2 + +# JSON-Files +[*.json] +indent_style = tab + +# ReST-Files +[*.rst] +indent_size = 3 +max_line_length = 80 + +# YAML-Files +[*.{yaml,yml}] +indent_size = 2 + +# package.json +# .travis.yml +[{package.json,.travis.yml}] +indent_size = 2 + +# TypoScript +[*.{typoscript,tsconfig}] +indent_size = 2 + +# XLF-Files +[*.xlf] +indent_style = tab + +# SQL-Files +[*.sql] +indent_style = tab +indent_size = 2 + +# .htaccess +[{_.htaccess,.htaccess}] +indent_style = tab From 02759167fa9712786760602a6e9962e5204c7736 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:54:54 +0100 Subject: [PATCH 07/37] [CLEANUP] CS compliance for TypoScript --- .../FluidStyledContent9/setup.typoscript | 8 +- Configuration/TypoScript/setup.typoscript | 142 +++++++++--------- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/Configuration/TypoScript/FluidStyledContent9/setup.typoscript b/Configuration/TypoScript/FluidStyledContent9/setup.typoscript index 78e188a3..a6b42c95 100644 --- a/Configuration/TypoScript/FluidStyledContent9/setup.typoscript +++ b/Configuration/TypoScript/FluidStyledContent9/setup.typoscript @@ -1,11 +1,13 @@ lib.contentElement { templateRootPaths { - 3001 = EXT:frontend_editing/Resources/Private/Templates/FluidStyledContent9/ + 3001 = EXT:frontend_editing/Resources/Private/Templates/FluidStyledContent9/ } + partialRootPaths { - 3001 = EXT:frontend_editing/Resources/Private/Partials/FluidStyledContent9/ + 3001 = EXT:frontend_editing/Resources/Private/Partials/FluidStyledContent9/ } + layoutRootPaths { - 2001 = EXT:frontend_editing/Resources/Private/Layouts/FluidStyledContent9/ + 2001 = EXT:frontend_editing/Resources/Private/Layouts/FluidStyledContent9/ } } diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 2905a2bb..9f3345ab 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,92 +1,92 @@ [backend.user.isLoggedIn] -lib.fluidContent { + lib.fluidContent { stdWrap { - editIcons = tt_content:header + editIcons = tt_content:header } -} - -lib.contentElement.stdWrap < lib.fluidContent.stdWrap - -tt_content.bullets.stdWrap < lib.fluidContent.stdWrap -tt_content.div.stdWrap < lib.fluidContent.stdWrap -tt_content.header.stdWrap < lib.fluidContent.stdWrap -tt_content.html.stdWrap < lib.fluidContent.stdWrap -tt_content.image.stdWrap < lib.fluidContent.stdWrap -tt_content.list.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap -tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap -tt_content.table.stdWrap < lib.fluidContent.stdWrap -tt_content.text.stdWrap < lib.fluidContent.stdWrap -tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap -tt_content.textpic.stdWrap < lib.fluidContent.stdWrap -tt_content.uploads.stdWrap < lib.fluidContent.stdWrap -tt_content.mailform.stdWrap < lib.fluidContent.stdWrap - -config.tx_extbase { + } + + lib.contentElement.stdWrap < lib.fluidContent.stdWrap + + tt_content.bullets.stdWrap < lib.fluidContent.stdWrap + tt_content.div.stdWrap < lib.fluidContent.stdWrap + tt_content.header.stdWrap < lib.fluidContent.stdWrap + tt_content.html.stdWrap < lib.fluidContent.stdWrap + tt_content.image.stdWrap < lib.fluidContent.stdWrap + tt_content.list.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap + tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap + tt_content.table.stdWrap < lib.fluidContent.stdWrap + tt_content.text.stdWrap < lib.fluidContent.stdWrap + tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap + tt_content.textpic.stdWrap < lib.fluidContent.stdWrap + tt_content.uploads.stdWrap < lib.fluidContent.stdWrap + tt_content.mailform.stdWrap < lib.fluidContent.stdWrap + + config.tx_extbase { objects { - TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView + TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView } -} + } -# Prevent links from being parsed to FE url -lib.parseFunc_RTE.tags.a > + # Prevent links from being parsed to FE url + lib.parseFunc_RTE.tags.a > [global] [backend.user.isLoggedIn] - config.tx_frontendediting { - # These transformations are applied to the page being edited to ensure features work as expected and inceptions - # are avoided. - pageContentPreProcessing { - parseFunc { - tags { - form = TEXT - form { - current = 1 - - # Add frontend_editing=true if this is a GET form (rather than POST) - innerWrap = | - innerWrap.if { - value.data = parameters : method - value.case = lower - equals = get - } - - dataWrap =
|
- } - } + config.tx_frontendediting { + # These transformations are applied to the page being edited to ensure features work as expected and inceptions + # are avoided. + pageContentPreProcessing { + parseFunc { + tags { + form = TEXT + form { + current = 1 + + # Add frontend_editing=true if this is a GET form (rather than POST) + innerWrap = | + innerWrap.if { + value.data = parameters : method + value.case = lower + equals = get } - HTMLparser = 1 - HTMLparser { - keepNonMatchedTags = 1 + dataWrap =
|
+ } + } + } - tags { - a.fixAttrib { - href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl + HTMLparser = 1 + HTMLparser { + keepNonMatchedTags = 1 - target.list = _self - } + tags { + a.fixAttrib { + href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl - form.fixAttrib { - action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl + target.list = _self + } - target.list = _self - } - } - } + form.fixAttrib { + action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl + + target.list = _self + } } + } } + } -[global] \ No newline at end of file +[global] From 4a67d3928b515aa27a194dbc40e22b72c84eb91c Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 12:56:57 +0100 Subject: [PATCH 08/37] [CLEANUP] CS compliance for PHP --- Classes/Controller/FrontendEditingModuleController.php | 2 +- Classes/Controller/ReceiverController.php | 4 ++-- Classes/Hook/FrontendEditingInitializationHook.php | 3 +-- Classes/Middleware/BackendUserRedirectToFrontend.php | 4 +--- Classes/Middleware/FrontendEditingAspect.php | 2 +- Classes/ViewHelpers/ContentEditableViewHelper.php | 4 ++-- Classes/ViewHelpers/CustomDropZoneViewHelper.php | 2 +- Classes/ViewHelpers/SvgViewHelper.php | 2 +- Configuration/RequestMiddlewares.php | 1 - 9 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Classes/Controller/FrontendEditingModuleController.php b/Classes/Controller/FrontendEditingModuleController.php index 151f700c..fd875863 100644 --- a/Classes/Controller/FrontendEditingModuleController.php +++ b/Classes/Controller/FrontendEditingModuleController.php @@ -1,6 +1,6 @@ getParsedBody()['data'], $data); - $this->newAction($data['edit'], $data['defVals'], (int) $request->getQueryParams()['page']); + $this->newAction($data['edit'], $data['defVals'], (int)$request->getQueryParams()['page']); break; case 'hide': $this->hideAction( @@ -233,7 +233,7 @@ protected function newAction(array $edit, array $defVals, int $pid) ); } - if ((int) array_keys($edit[$table])[0] < 0) { + if ((int)array_keys($edit[$table])[0] < 0) { $defVals[$table]['pid'] = array_keys($edit[$table])[0]; } else { $defVals[$table]['pid'] = $pid; diff --git a/Classes/Hook/FrontendEditingInitializationHook.php b/Classes/Hook/FrontendEditingInitializationHook.php index cd7a4db2..f9c5cde3 100644 --- a/Classes/Hook/FrontendEditingInitializationHook.php +++ b/Classes/Hook/FrontendEditingInitializationHook.php @@ -30,7 +30,6 @@ use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\TypoScript\TypoScriptService; -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; @@ -385,7 +384,7 @@ protected function loadJavascriptResources() GeneralUtility::getFileAbsFileName( 'EXT:rte_ckeditor/Resources/Public/JavaScript/Contrib/' ) - )) .';', + )) . ';', true, true ); diff --git a/Classes/Middleware/BackendUserRedirectToFrontend.php b/Classes/Middleware/BackendUserRedirectToFrontend.php index aa771697..474e495d 100644 --- a/Classes/Middleware/BackendUserRedirectToFrontend.php +++ b/Classes/Middleware/BackendUserRedirectToFrontend.php @@ -1,5 +1,5 @@ [ From 14fab171bdfeba6aa1178c55c8f77aa74f7c1e31 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 14:35:20 +0100 Subject: [PATCH 09/37] [CLEANUP] CS fix TypoScript indentation --- Configuration/TypoScript/setup.typoscript | 136 +++++++++++----------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 9f3345ab..4f6694b2 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,92 +1,92 @@ [backend.user.isLoggedIn] - lib.fluidContent { - stdWrap { - editIcons = tt_content:header - } +lib.fluidContent { + stdWrap { + editIcons = tt_content:header } - - lib.contentElement.stdWrap < lib.fluidContent.stdWrap - - tt_content.bullets.stdWrap < lib.fluidContent.stdWrap - tt_content.div.stdWrap < lib.fluidContent.stdWrap - tt_content.header.stdWrap < lib.fluidContent.stdWrap - tt_content.html.stdWrap < lib.fluidContent.stdWrap - tt_content.image.stdWrap < lib.fluidContent.stdWrap - tt_content.list.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap - tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap - tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap - tt_content.table.stdWrap < lib.fluidContent.stdWrap - tt_content.text.stdWrap < lib.fluidContent.stdWrap - tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap - tt_content.textpic.stdWrap < lib.fluidContent.stdWrap - tt_content.uploads.stdWrap < lib.fluidContent.stdWrap - tt_content.mailform.stdWrap < lib.fluidContent.stdWrap - - config.tx_extbase { - objects { - TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView - } +} + +lib.contentElement.stdWrap < lib.fluidContent.stdWrap + +tt_content.bullets.stdWrap < lib.fluidContent.stdWrap +tt_content.div.stdWrap < lib.fluidContent.stdWrap +tt_content.header.stdWrap < lib.fluidContent.stdWrap +tt_content.html.stdWrap < lib.fluidContent.stdWrap +tt_content.image.stdWrap < lib.fluidContent.stdWrap +tt_content.list.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap +tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap +tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap +tt_content.table.stdWrap < lib.fluidContent.stdWrap +tt_content.text.stdWrap < lib.fluidContent.stdWrap +tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap +tt_content.textpic.stdWrap < lib.fluidContent.stdWrap +tt_content.uploads.stdWrap < lib.fluidContent.stdWrap +tt_content.mailform.stdWrap < lib.fluidContent.stdWrap + +config.tx_extbase { + objects { + TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView } +} - # Prevent links from being parsed to FE url - lib.parseFunc_RTE.tags.a > +# Prevent links from being parsed to FE url +lib.parseFunc_RTE.tags.a > [global] [backend.user.isLoggedIn] - config.tx_frontendediting { - # These transformations are applied to the page being edited to ensure features work as expected and inceptions - # are avoided. - pageContentPreProcessing { - parseFunc { - tags { - form = TEXT - form { - current = 1 - - # Add frontend_editing=true if this is a GET form (rather than POST) - innerWrap = | - innerWrap.if { - value.data = parameters : method - value.case = lower - equals = get - } - - dataWrap =
|
+config.tx_frontendediting { + # These transformations are applied to the page being edited to ensure features work as expected and inceptions + # are avoided. + pageContentPreProcessing { + parseFunc { + tags { + form = TEXT + form { + current = 1 + + # Add frontend_editing=true if this is a GET form (rather than POST) + innerWrap = | + innerWrap.if { + value.data = parameters : method + value.case = lower + equals = get } + + dataWrap =
|
} } + } - HTMLparser = 1 - HTMLparser { - keepNonMatchedTags = 1 + HTMLparser = 1 + HTMLparser { + keepNonMatchedTags = 1 - tags { - a.fixAttrib { - href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl + tags { + a.fixAttrib { + href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl - target.list = _self - } + target.list = _self + } - form.fixAttrib { - action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl + form.fixAttrib { + action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl - target.list = _self - } + target.list = _self } } } } +} [global] From 73454c5956ceb10fb9d4cd0957bea40399adf0a8 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 14:35:53 +0100 Subject: [PATCH 10/37] Revert "[CLEANUP] CS fix TypoScript indentation" This reverts commit 14fab171 --- Configuration/TypoScript/setup.typoscript | 136 +++++++++++----------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 4f6694b2..9f3345ab 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -1,92 +1,92 @@ [backend.user.isLoggedIn] -lib.fluidContent { - stdWrap { - editIcons = tt_content:header + lib.fluidContent { + stdWrap { + editIcons = tt_content:header + } } -} - -lib.contentElement.stdWrap < lib.fluidContent.stdWrap - -tt_content.bullets.stdWrap < lib.fluidContent.stdWrap -tt_content.div.stdWrap < lib.fluidContent.stdWrap -tt_content.header.stdWrap < lib.fluidContent.stdWrap -tt_content.html.stdWrap < lib.fluidContent.stdWrap -tt_content.image.stdWrap < lib.fluidContent.stdWrap -tt_content.list.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap -tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap -tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap -tt_content.table.stdWrap < lib.fluidContent.stdWrap -tt_content.text.stdWrap < lib.fluidContent.stdWrap -tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap -tt_content.textpic.stdWrap < lib.fluidContent.stdWrap -tt_content.uploads.stdWrap < lib.fluidContent.stdWrap -tt_content.mailform.stdWrap < lib.fluidContent.stdWrap - -config.tx_extbase { - objects { - TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView + + lib.contentElement.stdWrap < lib.fluidContent.stdWrap + + tt_content.bullets.stdWrap < lib.fluidContent.stdWrap + tt_content.div.stdWrap < lib.fluidContent.stdWrap + tt_content.header.stdWrap < lib.fluidContent.stdWrap + tt_content.html.stdWrap < lib.fluidContent.stdWrap + tt_content.image.stdWrap < lib.fluidContent.stdWrap + tt_content.list.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_abstract.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_categorized_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_recently_updated.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_related_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_section.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_section_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_sitemap.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_sitemap_pages.stdWrap < lib.fluidContent.stdWrap + tt_content.menu_subpages.stdWrap < lib.fluidContent.stdWrap + tt_content.shortcut.stdWrap < lib.fluidContent.stdWrap + tt_content.table.stdWrap < lib.fluidContent.stdWrap + tt_content.text.stdWrap < lib.fluidContent.stdWrap + tt_content.textmedia.stdWrap < lib.fluidContent.stdWrap + tt_content.textpic.stdWrap < lib.fluidContent.stdWrap + tt_content.uploads.stdWrap < lib.fluidContent.stdWrap + tt_content.mailform.stdWrap < lib.fluidContent.stdWrap + + config.tx_extbase { + objects { + TYPO3\CMS\Extbase\Mvc\View\NotFoundView.className = TYPO3\CMS\FrontendEditing\Mvc\View\NotFoundView + } } -} -# Prevent links from being parsed to FE url -lib.parseFunc_RTE.tags.a > + # Prevent links from being parsed to FE url + lib.parseFunc_RTE.tags.a > [global] [backend.user.isLoggedIn] -config.tx_frontendediting { - # These transformations are applied to the page being edited to ensure features work as expected and inceptions - # are avoided. - pageContentPreProcessing { - parseFunc { - tags { - form = TEXT - form { - current = 1 - - # Add frontend_editing=true if this is a GET form (rather than POST) - innerWrap = | - innerWrap.if { - value.data = parameters : method - value.case = lower - equals = get + config.tx_frontendediting { + # These transformations are applied to the page being edited to ensure features work as expected and inceptions + # are avoided. + pageContentPreProcessing { + parseFunc { + tags { + form = TEXT + form { + current = 1 + + # Add frontend_editing=true if this is a GET form (rather than POST) + innerWrap = | + innerWrap.if { + value.data = parameters : method + value.case = lower + equals = get + } + + dataWrap =
|
} - - dataWrap =
|
} } - } - HTMLparser = 1 - HTMLparser { - keepNonMatchedTags = 1 + HTMLparser = 1 + HTMLparser { + keepNonMatchedTags = 1 - tags { - a.fixAttrib { - href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl + tags { + a.fixAttrib { + href.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->removeFrontendEditingInUrl - target.list = _self - } + target.list = _self + } - form.fixAttrib { - action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl + form.fixAttrib { + action.userFunc = TYPO3\CMS\FrontendEditing\UserFunc\HtmlParserUserFunc->addFrontendEditingInUrl - target.list = _self + target.list = _self + } } } } } -} [global] From 097ea38d3146bc2c3175314c7d168c0ad3975f61 Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 14:37:18 +0100 Subject: [PATCH 11/37] [TASK] Add TS lint configuration --- Configuration/TsLint.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Configuration/TsLint.yml diff --git a/Configuration/TsLint.yml b/Configuration/TsLint.yml new file mode 100644 index 00000000..ff4a20d0 --- /dev/null +++ b/Configuration/TsLint.yml @@ -0,0 +1,4 @@ +sniffs: + - class: Indentation + parameters: + indentConditions: true From 751edbc2a206a5b4528f4d21034e8bccd27c20bf Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 14:47:01 +0100 Subject: [PATCH 12/37] [TASK] Added PHP CS config from TYPO3 Core --- Build/.php_cs | 68 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/Build/.php_cs b/Build/.php_cs index a9134a89..7639cff1 100644 --- a/Build/.php_cs +++ b/Build/.php_cs @@ -20,7 +20,7 @@ * * And then simply run * - * $ php-cs-fixer fix --config ../Build/.php_cs + * $ ./bin/php-cs-fixer fix --config ./Build/.php_cs * * inside the TYPO3 directory. Warning: This may take up to 10 minutes. * @@ -34,6 +34,12 @@ if (PHP_SAPI !== 'cli') { // Define in which folders to search and which folders to exclude // Exclude some directories that are excluded by Git anyways to speed up the sniffing $finder = PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('typo3conf') + ->exclude('typo3temp') + ->exclude('typo3/sysext/core/Tests/Acceptance/Support/_generated') + ->notName('install.php') + ->notName('index.php') ->in(__DIR__ . '/../'); // Return a Code Sniffing configuration using // all sniffers needed for PSR-2 @@ -47,41 +53,53 @@ $finder = PhpCsFixer\Finder::create() return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules([ - '@PSR2' => true, '@DoctrineAnnotation' => true, - 'no_leading_import_slash' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_unused_imports' => true, - 'concat_space' => ['spacing' => 'one'], - 'no_whitespace_in_blank_line' => true, - 'ordered_imports' => true, - 'single_quote' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, - 'phpdoc_no_package' => true, - 'phpdoc_scalar' => true, - 'no_blank_lines_after_phpdoc' => true, + '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], - 'whitespace_after_comma_in_array' => true, + 'blank_line_after_opening_tag' => true, + 'braces' => ['allow_single_line_closure' => true], + 'cast_spaces' => ['space' => 'none'], + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'dir_constant' => true, 'function_typehint_space' => true, 'hash_to_slash_comment' => true, - 'no_alias_functions' => true, 'lowercase_cast' => true, - 'no_leading_namespace_whitespace' => true, + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], + 'modernize_types_casting' => true, 'native_function_casing' => true, + 'new_with_braces' => true, + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_consecutive_blank_lines' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline_array' => true, 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_whitespace_in_blank_line' => true, + 'ordered_imports' => true, + 'php_unit_construct' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame'], + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_no_access' => true, 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, 'phpdoc_trim' => true, - 'no_superfluous_elseif' => true, - 'no_useless_else' => true, 'phpdoc_types' => true, 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'return_type_declaration' => ['space_before' => 'none'], - 'cast_spaces' => ['space' => 'none'], - 'declare_equal_normalize' => ['space' => 'single'], - 'dir_constant' => true, - 'phpdoc_no_access' => true + 'single_quote' => true, + 'single_trait_insert_per_statement' => true, + 'whitespace_after_comma_in_array' => true, ]) - ->setFinder($finder); \ No newline at end of file + ->setFinder($finder); From 7bb5ba7394a039e643268e0b390fc0ed8698237e Mon Sep 17 00:00:00 2001 From: mabolek Date: Thu, 3 Dec 2020 14:52:07 +0100 Subject: [PATCH 13/37] [CLEANUP] TypoScript CS fixes --- Configuration/TsLint.yml | 2 ++ Configuration/TypoScript/setup.typoscript | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Configuration/TsLint.yml b/Configuration/TsLint.yml index ff4a20d0..b7bd2ee6 100644 --- a/Configuration/TsLint.yml +++ b/Configuration/TsLint.yml @@ -1,4 +1,6 @@ sniffs: - class: Indentation parameters: + useSpaces: true + indentPerLevel: 4 indentConditions: true diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 9f3345ab..caecb4ce 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -58,8 +58,10 @@ # Add frontend_editing=true if this is a GET form (rather than POST) innerWrap = | innerWrap.if { - value.data = parameters : method - value.case = lower + value { + data = parameters : method + case = lower + } equals = get } From 6133f794984d64bb610e5e3b577ffa8e83b55c2c Mon Sep 17 00:00:00 2001 From: mabolek Date: Fri, 18 Dec 2020 09:09:06 +0100 Subject: [PATCH 14/37] [TASK] Migrate to php-cs-fixer for sniff and fix --- composer.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index c2b84978..dd6dac3e 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,8 @@ }, "scripts": { "ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l", - "ci:php:sniff": "phpcs Classes Tests", - "cs:php:fix": "phpcbf Classes Tests", + "ci:php:sniff": "php-cs-fixer fix --config=Build/.php_cs -v --dry-run --using-cache=no", + "cs:php:fix": "php-cs-fixer fix --config=Build/.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'", @@ -66,8 +66,6 @@ "@php -r 'is_dir($extFolder=__DIR__.\"/.Build/public/typo3conf/ext/\") || mkdir($extFolder, 0777, true);'", "@php -r 'file_exists($extFolder=__DIR__.\"/.Build/public/typo3conf/ext/frontend_editing\") || symlink(__DIR__,$extFolder);'" ], - "fix:php-cs": "php-cs-fixer fix", - "fix:php-sniff": "phpcbf Classes Tests", "post-autoload-dump": [ "@link-extension" ], From a99c4bd223f307bab3b32d161df63602d0ee26c8 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 11:40:24 +0100 Subject: [PATCH 15/37] [TASK] Set PHP 7.4 for code sniffer job --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc340042..01c46d27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,6 +62,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Configure PHP 7.4 + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + - name: Checkout uses: actions/checkout@v1 From 914d3fcb5223b1f7e442ee5cf545df272f3eae87 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 11:41:01 +0100 Subject: [PATCH 16/37] [TASK] Set PHP 7.4 for TS linter job --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01c46d27..d658f347 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Configure PHP 7.4 + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + - name: Checkout uses: actions/checkout@v1 From 003d6edef2c46fab48824004fe514b166654293b Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 11:45:43 +0100 Subject: [PATCH 17/37] [TASK] Set TS linter indent level to 2 --- Configuration/TsLint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/TsLint.yml b/Configuration/TsLint.yml index b7bd2ee6..9394b343 100644 --- a/Configuration/TsLint.yml +++ b/Configuration/TsLint.yml @@ -2,5 +2,5 @@ sniffs: - class: Indentation parameters: useSpaces: true - indentPerLevel: 4 + indentPerLevel: 2 indentConditions: true From b8c8fbf1e0e1fc9682e608270ffeb8da56cfd68b Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 11:49:29 +0100 Subject: [PATCH 18/37] [TASK] Move php-cs-fixer config to root directory --- Build/.php_cs => .php_cs | 0 composer.json | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename Build/.php_cs => .php_cs (100%) diff --git a/Build/.php_cs b/.php_cs similarity index 100% rename from Build/.php_cs rename to .php_cs diff --git a/composer.json b/composer.json index dd6dac3e..e07696a0 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,8 @@ }, "scripts": { "ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l", - "ci:php:sniff": "php-cs-fixer fix --config=Build/.php_cs -v --dry-run --using-cache=no", - "cs:php:fix": "php-cs-fixer fix --config=Build/.php_cs -v --using-cache=no", + "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no", + "cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'", From fea48ebe25b192af32d8a1bf9d64d01fec851f3d Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 11:50:54 +0100 Subject: [PATCH 19/37] [TASK] Delete .travis.yml --- .travis.yml | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 37b6913c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -php: - - 7.3 - -sudo: false - -addons: - apt: - packages: - - parallel - -env: - - NODE_VERSION="6.0" - -cache: - directories: - - $HOME/.composer/cache - -before_install: - - phpenv config-rm xdebug.ini - - nvm install $NODE_VERSION - - composer self-update - - composer --version - - composer install - - npm install - -script: - # Run full test suite and linting of the code base -# - > -# echo; -# echo "Building assets"; -# npm run build:suite -# - > -# echo; -# echo "Running unit tests"; -# .Build/bin/phpunit --colors -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit - - > - echo; - echo "Running PHP Coding Standards Fixer checks"; - .Build/bin/php-cs-fixer fix --config=Build/.php_cs -v --dry-run --using-cache=no --path-mode=intersection `git diff --name-only --diff-filter=ACMRTUXB $COMMIT_RANGE` \ No newline at end of file From a7a9aedd7151ff130bb68f1f6f40e794659d9698 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:00:07 +0100 Subject: [PATCH 20/37] [TASK] Set checkstyle format on php sniff --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e07696a0..b07a7619 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ }, "scripts": { "ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l", - "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no", + "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no --format=checkstyle", "cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", From cd427c401f0df206b029cfdacac185481807be39 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:04:48 +0100 Subject: [PATCH 21/37] [TASK] Enabled diff for PHP sniffer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b07a7619..06c2fc42 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ }, "scripts": { "ci:php:lint": "find *.php Classes/ Configuration/ Tests/ -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l", - "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no --format=checkstyle", + "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no --diff", "cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", From e1e49ab4d9fe35438d8269d553f7d1a2405a5f6e Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:08:49 +0100 Subject: [PATCH 22/37] [TASK] Fixed root directory --- .php_cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php_cs b/.php_cs index 7639cff1..766a2cb0 100644 --- a/.php_cs +++ b/.php_cs @@ -40,7 +40,7 @@ $finder = PhpCsFixer\Finder::create() ->exclude('typo3/sysext/core/Tests/Acceptance/Support/_generated') ->notName('install.php') ->notName('index.php') - ->in(__DIR__ . '/../'); + ->in(__DIR__); // Return a Code Sniffing configuration using // all sniffers needed for PSR-2 // and additionally: From 311b78445f55e74472bd1fe2f58bce8a7a6e2741 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:12:07 +0100 Subject: [PATCH 23/37] [TASK] Fixed root directory --- .php_cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.php_cs b/.php_cs index 766a2cb0..ff98b285 100644 --- a/.php_cs +++ b/.php_cs @@ -31,16 +31,7 @@ if (PHP_SAPI !== 'cli') { die('This script supports command line usage only. Please check your command.'); } -// Define in which folders to search and which folders to exclude -// Exclude some directories that are excluded by Git anyways to speed up the sniffing -$finder = PhpCsFixer\Finder::create() - ->exclude('vendor') - ->exclude('typo3conf') - ->exclude('typo3temp') - ->exclude('typo3/sysext/core/Tests/Acceptance/Support/_generated') - ->notName('install.php') - ->notName('index.php') - ->in(__DIR__); + // Return a Code Sniffing configuration using // all sniffers needed for PSR-2 // and additionally: @@ -102,4 +93,4 @@ return PhpCsFixer\Config::create() 'single_trait_insert_per_statement' => true, 'whitespace_after_comma_in_array' => true, ]) - ->setFinder($finder); + ->setFinder(PhpCsFixer\Finder::create()->in(__DIR__)); From cc9e0719f65e7645f36568671a1875a86908c116 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:12:39 +0100 Subject: [PATCH 24/37] [CLEANUP] CS fixes --- .../NewContentElementController.php | 3 +- Classes/Controller/EditorController.php | 3 +- .../FrontendEditingModuleController.php | 2 +- Classes/Controller/ReceiverController.php | 3 +- .../FrontendEditingDropzoneModifier.php | 3 +- Classes/EditingPanel/FrontendEditingPanel.php | 3 +- Classes/Hook/ContentObjectRendererHook.php | 3 +- .../FrontendEditingInitializationHook.php | 5 +-- .../BackendUserRedirectToFrontend.php | 5 +-- Classes/Middleware/FrontendEditingAspect.php | 3 +- .../Middleware/FrontendEditingInitiator.php | 3 +- Classes/Mvc/View/NotFoundView.php | 3 +- Classes/RequestPreProcess/CeBullets.php | 3 +- Classes/RequestPreProcess/CeHeader.php | 3 +- Classes/RequestPreProcess/CeTable.php | 5 +-- .../RequestPreProcessInterface.php | 3 +- Classes/Service/AccessService.php | 3 +- .../Service/ContentEditableWrapperService.php | 3 +- .../ExtensionManagerConfigurationService.php | 3 +- Classes/UserFunc/HtmlParserUserFunc.php | 3 +- Classes/Utility/FrontendEditingUtility.php | 3 +- .../ViewHelpers/ContentEditableViewHelper.php | 1 + .../ViewHelpers/CustomDropZoneViewHelper.php | 1 + .../IsFrontendEditingActiveViewHelper.php | 1 + .../IsPlaceholderEnabledViewHelper.php | 1 + Classes/ViewHelpers/SvgViewHelper.php | 3 +- Configuration/TCA/Overrides/sys_template.php | 1 + .../EditingPanel/FrontendEditingPanelTest.php | 5 +-- .../Unit/Fixtures/ContentEditableFixtures.php | 3 +- .../ContentEditableWrapperServiceTest.php | 35 +++++++++---------- ...tensionManagerConfigurationServiceTest.php | 5 +-- .../ContentEditableViewHelperTest.php | 23 ++++++------ .../CustomDropZoneViewHelperTest.php | 27 +++++++------- Tests/Unit/ViewHelpers/SvgViewHelperTest.php | 21 +++++------ ext_emconf.php | 1 + ext_localconf.php | 1 + ext_tables.php | 1 + 37 files changed, 116 insertions(+), 82 deletions(-) diff --git a/Classes/Backend/Controller/ContentElement/NewContentElementController.php b/Classes/Backend/Controller/ContentElement/NewContentElementController.php index e1e40f4b..0c22e672 100644 --- a/Classes/Backend/Controller/ContentElement/NewContentElementController.php +++ b/Classes/Backend/Controller/ContentElement/NewContentElementController.php @@ -1,5 +1,6 @@ getTSConfig()['frontend_editing.']['disallow_backend_access'] ?? false); + return (bool)($user->getTSConfig()['frontend_editing.']['disallow_backend_access'] ?? false); } /** diff --git a/Classes/Middleware/FrontendEditingAspect.php b/Classes/Middleware/FrontendEditingAspect.php index 74173630..0f9df370 100644 --- a/Classes/Middleware/FrontendEditingAspect.php +++ b/Classes/Middleware/FrontendEditingAspect.php @@ -1,5 +1,6 @@ nodeValue); } - $doc = new \DOMDOcument; + $doc = new \DOMDOcument(); $doc->loadxml($record['pi_flexform']); $replacement = $doc->createDocumentFragment(); diff --git a/Classes/RequestPreProcess/RequestPreProcessInterface.php b/Classes/RequestPreProcess/RequestPreProcessInterface.php index edd12fd0..2486fd0c 100644 --- a/Classes/RequestPreProcess/RequestPreProcessInterface.php +++ b/Classes/RequestPreProcess/RequestPreProcessInterface.php @@ -1,5 +1,6 @@ uc['tx_frontend_editing_enable'] = $allowEditing; $subject = new FrontendEditingPanel(); - $this->assertSame( + self::assertSame( $expect, $subject->editIcons( $content, diff --git a/Tests/Unit/Fixtures/ContentEditableFixtures.php b/Tests/Unit/Fixtures/ContentEditableFixtures.php index 8855e4bc..95d13618 100644 --- a/Tests/Unit/Fixtures/ContentEditableFixtures.php +++ b/Tests/Unit/Fixtures/ContentEditableFixtures.php @@ -1,5 +1,6 @@ fixtures = new ContentEditableFixtures(); } - /** - */ protected function tearDown() { unset($this->subject); @@ -66,7 +65,7 @@ public function getWrappedContent() $this->fixtures->getContent() ); - $this->assertSame( + self::assertSame( $wrappedContent, $this->fixtures->getWrappedExpectedContent() ); @@ -84,7 +83,7 @@ public function getWrapContent() $this->fixtures->getContent() ); - $this->assertSame( + self::assertSame( $wrapContent, $this->fixtures->getWrapExpectedContent() ); @@ -100,7 +99,7 @@ public function getWrapContentWithDropzone() $this->fixtures->getUid(), $this->fixtures->getContent() ); - $this->assertSame( + self::assertSame( $wrapContent, $this->fixtures->getWrapWithDropzoneExpectedContent() ); @@ -119,10 +118,10 @@ public function tryWrapContentAndExpectAnException() $this->fixtures->getContent() ); } catch (\Exception $exception) { - $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } - $this->fail('Expected Property "table" missing Exception has not been raised.'); + self::fail('Expected Property "table" missing Exception has not been raised.'); } /** @@ -138,10 +137,10 @@ public function tryWrapContentAndExpectAnExceptionForMissingTable() $this->fixtures->getContent() ); } catch (\Exception $exception) { - $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } - $this->fail('Expected Property "table" missing Exception has not been raised.'); + self::fail('Expected Property "table" missing Exception has not been raised.'); } /** @@ -157,10 +156,10 @@ public function tryWrapContentAndExpectAnExceptionForMissingUid() $this->fixtures->getContent() ); } catch (\Exception $exception) { - $this->assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!'); + self::assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!'); return; } - $this->fail('Expected Property "uid" missing Exception has not been raised.'); + self::fail('Expected Property "uid" missing Exception has not been raised.'); } /** * @test @@ -174,10 +173,10 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingTable() $this->fixtures->getContent() ); } catch (\Exception $exception) { - $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } - $this->fail('Expected Property "table" missing Exception has not been raised.'); + self::fail('Expected Property "table" missing Exception has not been raised.'); } /** @@ -192,9 +191,9 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingUid() $this->fixtures->getContent() ); } catch (\Exception $exception) { - $this->assertEquals($exception->getMessage(), 'Property "uid" is not valid!'); + self::assertEquals($exception->getMessage(), 'Property "uid" is not valid!'); return; } - $this->fail('Expected Property "uid" missing Exception has not been raised.'); + self::fail('Expected Property "uid" missing Exception has not been raised.'); } } diff --git a/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php b/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php index 2a268f41..97bb638f 100644 --- a/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php +++ b/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php @@ -1,5 +1,6 @@ assertSame( + self::assertSame( ExtensionManagerConfigurationService::getSettings(), [] ); diff --git a/Tests/Unit/ViewHelpers/ContentEditableViewHelperTest.php b/Tests/Unit/ViewHelpers/ContentEditableViewHelperTest.php index 65563ed7..212d2bf0 100644 --- a/Tests/Unit/ViewHelpers/ContentEditableViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/ContentEditableViewHelperTest.php @@ -1,5 +1,6 @@ getMock(ContentEditableViewHelper::class, ['registerArgument']); - $instance->expects($this->at(0))->method('registerArgument')->with( + $instance->expects(self::at(0))->method('registerArgument')->with( 'table', 'string', - $this->anything(), + self::anything(), true, false ); - $instance->expects($this->at(1))->method('registerArgument')->with( + $instance->expects(self::at(1))->method('registerArgument')->with( 'field', 'string', - $this->anything(), + self::anything(), false, false ); - $instance->expects($this->at(2))->method('registerArgument')->with( + $instance->expects(self::at(2))->method('registerArgument')->with( 'uid', 'string', - $this->anything(), + self::anything(), true, false ); @@ -70,11 +71,11 @@ public function testInitializeArgumentsRegistersExpectedArguments() public function testRenderWithoutFrontendEditingEnabled($value, array $arguments, $expected) { $instance = $this->getMock(ContentEditableViewHelper::class, ['renderChildren']); - $instance->expects($this->once())->method('renderChildren')->willReturn($value); + $instance->expects(self::once())->method('renderChildren')->willReturn($value); $instance->setArguments($arguments); $instance->setRenderingContext(new RenderingContextFixture()); $result = $instance->render(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -96,11 +97,11 @@ public function testRenderWithFrontendEditingEnabled($value, array $arguments, $ ); ContentEditableFixtures::setAccessServiceEnabled(true); $instance = $this->getMock(ContentEditableViewHelper::class, ['renderChildren']); - $instance->expects($this->once())->method('renderChildren')->willReturn($value); + $instance->expects(self::once())->method('renderChildren')->willReturn($value); $instance->setArguments($arguments); $instance->setRenderingContext(new RenderingContextFixture()); $result = $instance->render(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** diff --git a/Tests/Unit/ViewHelpers/CustomDropZoneViewHelperTest.php b/Tests/Unit/ViewHelpers/CustomDropZoneViewHelperTest.php index 66b8043a..e5c5acb6 100644 --- a/Tests/Unit/ViewHelpers/CustomDropZoneViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/CustomDropZoneViewHelperTest.php @@ -1,5 +1,6 @@ getMock(CustomDropZoneViewHelper::class, ['registerArgument']); - $instance->expects($this->at(0))->method('registerArgument')->with( + $instance->expects(self::at(0))->method('registerArgument')->with( 'tables', 'array', - $this->anything(), + self::anything(), true, false ); - $instance->expects($this->at(1))->method('registerArgument')->with( + $instance->expects(self::at(1))->method('registerArgument')->with( 'fields', 'array', - $this->anything(), + self::anything(), false, false ); - $instance->expects($this->at(2))->method('registerArgument')->with( + $instance->expects(self::at(2))->method('registerArgument')->with( 'pageUid', 'string', - $this->anything(), + self::anything(), false, false ); - $instance->expects($this->at(3))->method('registerArgument')->with( + $instance->expects(self::at(3))->method('registerArgument')->with( 'prepend', 'bool', - $this->anything(), + self::anything(), false, false ); @@ -75,11 +76,11 @@ public function testInitializeArgumentsRegistersExpectedArguments() public function testRenderWithoutFrontendEditingEnabled($value, array $arguments, $expected) { $instance = $this->getMock(CustomDropZoneViewHelper::class, ['renderChildren']); - $instance->expects($this->once())->method('renderChildren')->willReturn($value); + $instance->expects(self::once())->method('renderChildren')->willReturn($value); $instance->setArguments($arguments); $instance->setRenderingContext(new RenderingContextFixture()); $result = $instance->render(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** @@ -92,11 +93,11 @@ public function testRenderWithFrontendEditingEnabled($value, array $arguments, $ { ContentEditableFixtures::setAccessServiceEnabled(true); $instance = $this->getMock(CustomDropZoneViewHelper::class, ['renderChildren']); - $instance->expects($this->once())->method('renderChildren')->willReturn($value); + $instance->expects(self::once())->method('renderChildren')->willReturn($value); $instance->setArguments($arguments); $instance->setRenderingContext(new RenderingContextFixture()); $result = $instance->render(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** diff --git a/Tests/Unit/ViewHelpers/SvgViewHelperTest.php b/Tests/Unit/ViewHelpers/SvgViewHelperTest.php index 58262c5f..4582fc9b 100644 --- a/Tests/Unit/ViewHelpers/SvgViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/SvgViewHelperTest.php @@ -1,5 +1,6 @@ getMock(SvgViewHelper::class, ['registerArgument']); - $instance->expects($this->at(0))->method('registerArgument')->with( + $instance->expects(self::at(0))->method('registerArgument')->with( 'source', 'string', - $this->anything(), + self::anything(), true, false ); - $instance->expects($this->at(1))->method('registerArgument')->with( + $instance->expects(self::at(1))->method('registerArgument')->with( 'class', 'string', - $this->anything(), + self::anything(), false, false ); - $instance->expects($this->at(2))->method('registerArgument')->with( + $instance->expects(self::at(2))->method('registerArgument')->with( 'width', 'int', - $this->anything(), + self::anything(), false, false ); - $instance->expects($this->at(3))->method('registerArgument')->with( + $instance->expects(self::at(3))->method('registerArgument')->with( 'height', 'int', - $this->anything(), + self::anything(), false, false ); @@ -78,7 +79,7 @@ public function testRenderWithWrongPathToIcon($value, array $arguments, $expecte $instance->setArguments($arguments); $instance->setRenderingContext(new RenderingContextFixture()); $result = $instance->render(); - $this->assertEquals($expected, $result); + self::assertEquals($expected, $result); } /** diff --git a/ext_emconf.php b/ext_emconf.php index f06eb6b2..770d086c 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -1,4 +1,5 @@ 'Frontend Editing', 'description' => 'Enable editors to work with the content in the most intuitive way possible', diff --git a/ext_localconf.php b/ext_localconf.php index 667bdecc..7f415041 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,4 +1,5 @@ viewhelper by the one from EXT:frontend_editing diff --git a/ext_tables.php b/ext_tables.php index 347cb3e6..9787249a 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,4 +1,5 @@ Date: Tue, 12 Jan 2021 12:31:06 +0100 Subject: [PATCH 25/37] [TASK] Exclude PHP <7.4 for TYPO3 v10.4 --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d658f347..1312a5cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,6 +113,11 @@ jobs: database-image: mariadb:latest - typo3-version: "^10.4" database-image: mariadb:latest + exlclude: + - typo3-version: "^10.4" + php-version: + - 7.2 + - 7.3 services: mysql: From 16a7384196b387e578257109abe8a3cb2ed24748 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:37:43 +0100 Subject: [PATCH 26/37] [TASK] Include PHP <7.4 for TYPO3 v10.4 --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1312a5cb..d658f347 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,11 +113,6 @@ jobs: database-image: mariadb:latest - typo3-version: "^10.4" database-image: mariadb:latest - exlclude: - - typo3-version: "^10.4" - php-version: - - 7.2 - - 7.3 services: mysql: From 9508abe801efc3e2c77ef8b37999d3f99279861c Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:40:11 +0100 Subject: [PATCH 27/37] [TASK] Disable composer v2 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d658f347..6caf1dfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: matrix: composer-version: - v1 - - v2 + #- v2 typo3-version: - "^9.5" - "^10.4" From e609f1ddf350b64a9cd1fb70f732bfbb1f71ae33 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:45:45 +0100 Subject: [PATCH 28/37] [TASK] Include testing framework 5 and enable composer v2 --- .github/workflows/ci.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6caf1dfd..d658f347 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: matrix: composer-version: - v1 - #- v2 + - v2 typo3-version: - "^9.5" - "^10.4" diff --git a/composer.json b/composer.json index 06c2fc42..cd417379 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "typo3/cms-core": "^9.5 || ^10.4" }, "require-dev": { - "nimut/testing-framework": "^4.2", + "nimut/testing-framework": "^4.2 || ^5.0", "squizlabs/php_codesniffer": "^3.3", "phpunit/phpunit": "^6.0", "friendsofphp/php-cs-fixer": "^2.15", From 46beb355fb01f4857a6b2fc222d0ee3884344175 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:49:47 +0100 Subject: [PATCH 29/37] [TASK] Require nimut/testing-framework ^5.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index cd417379..918e9aca 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "typo3/cms-core": "^9.5 || ^10.4" }, "require-dev": { - "nimut/testing-framework": "^4.2 || ^5.0", + "nimut/testing-framework": "^5.0", "squizlabs/php_codesniffer": "^3.3", "phpunit/phpunit": "^6.0", "friendsofphp/php-cs-fixer": "^2.15", From 52a2583defc294aab8d37ab0ec2a532186bd6632 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 12:54:22 +0100 Subject: [PATCH 30/37] [TASK] Fixed test root path --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d658f347..c71de93e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,12 +168,12 @@ jobs: - name: Run unit tests # Environment variable can be removed when TYPO3 v7 support ends env: - TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/pxa_siteimprove/.Build/public + TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/frontend_editing/.Build/public run: composer ci:tests:unit - name: Run functional tests env: - TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/pxa_siteimprove/.Build/public + TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/frontend_editing/.Build/public typo3DatabaseHost: 127.0.0.1 typo3DatabasePort: ${{ job.services.mysql.ports['3306'] }} typo3DatabaseName: typo3 From c3570ef625d8690bc1c72b453216d851b3b76e8c Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 13:02:45 +0100 Subject: [PATCH 31/37] [TASK] Fixed test root path --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c71de93e..43fcd039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,12 +168,12 @@ jobs: - name: Run unit tests # Environment variable can be removed when TYPO3 v7 support ends env: - TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/frontend_editing/.Build/public + TYPO3_PATH_ROOT: /home/runner/work/frontend_editing/frontend_editing/.Build/public run: composer ci:tests:unit - name: Run functional tests env: - TYPO3_PATH_ROOT: /home/runner/work/pxa_siteimprove/frontend_editing/.Build/public + TYPO3_PATH_ROOT: /home/runner/work/frontend_editing/frontend_editing/.Build/public typo3DatabaseHost: 127.0.0.1 typo3DatabasePort: ${{ job.services.mysql.ports['3306'] }} typo3DatabaseName: typo3 From d6e6cdb9d46be16e1992d90484634d53d88ea6c5 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 13:06:04 +0100 Subject: [PATCH 32/37] [TASK] Removed TYPO3 root path --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43fcd039..aef3b67b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -166,14 +166,10 @@ jobs: composer show - name: Run unit tests - # Environment variable can be removed when TYPO3 v7 support ends - env: - TYPO3_PATH_ROOT: /home/runner/work/frontend_editing/frontend_editing/.Build/public run: composer ci:tests:unit - name: Run functional tests env: - TYPO3_PATH_ROOT: /home/runner/work/frontend_editing/frontend_editing/.Build/public typo3DatabaseHost: 127.0.0.1 typo3DatabasePort: ${{ job.services.mysql.ports['3306'] }} typo3DatabaseName: typo3 From d0ada239fb3eb4e33bc6dd83f6c0b0e7d97a5548 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 13:24:05 +0100 Subject: [PATCH 33/37] [TASK] Updated unit tests --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 918e9aca..1aa001a4 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "ci:php:sniff": "php-cs-fixer fix --config=.php_cs -v --dry-run --using-cache=no --diff", "cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", - "ci:tests:unit": "find 'Tests/Unit' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running unit test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php {}'", + "ci:tests:unit": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit", "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'", "ci:tests": [ "@ci:tests:unit", @@ -80,7 +80,7 @@ "typo3/cms": { "extension-key": "frontend_editing", "cms-package-dir": "{$vendor-dir}/typo3/cms", - "web-dir": ".Build/Web" + "web-dir": ".Build/public" } } } From 149e62f363348473c4c994c96baf60d10ddf62c3 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 13:38:25 +0100 Subject: [PATCH 34/37] [TASK] Ignore /var --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a41d2a17..f0106d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ package-lock.json # PHP CS fix caches .php_cs.cache + +/var From 86ee420cc5cd4be72cd49dacafd4915724b980d6 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 14:21:32 +0100 Subject: [PATCH 35/37] [TASK] Remove unused version code --- Classes/Service/ExtensionManagerConfigurationService.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Classes/Service/ExtensionManagerConfigurationService.php b/Classes/Service/ExtensionManagerConfigurationService.php index b20deeb7..901aab1b 100644 --- a/Classes/Service/ExtensionManagerConfigurationService.php +++ b/Classes/Service/ExtensionManagerConfigurationService.php @@ -33,10 +33,6 @@ class ExtensionManagerConfigurationService */ public static function getSettings(): array { - $typo3VersionNumber = VersionNumberUtility::convertVersionNumberToInteger( - VersionNumberUtility::getNumericTypo3Version() - ); - $settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('frontend_editing'); if (!is_array($settings)) { From 09ec5f49c469cf76de5ac7dd67ca292835465545 Mon Sep 17 00:00:00 2001 From: mabolek Date: Tue, 12 Jan 2021 16:45:28 +0100 Subject: [PATCH 36/37] [TASK] Refactored ExtensionManagerConfigurationService into a utility The class was being called as non-static, but had only static methods. --- .../ConfigurationUtility.php} | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) rename Classes/{Service/ExtensionManagerConfigurationService.php => Utility/ConfigurationUtility.php} (53%) diff --git a/Classes/Service/ExtensionManagerConfigurationService.php b/Classes/Utility/ConfigurationUtility.php similarity index 53% rename from Classes/Service/ExtensionManagerConfigurationService.php rename to Classes/Utility/ConfigurationUtility.php index 901aab1b..34e579df 100644 --- a/Classes/Service/ExtensionManagerConfigurationService.php +++ b/Classes/Utility/ConfigurationUtility.php @@ -2,8 +2,6 @@ declare(strict_types=1); -namespace TYPO3\CMS\FrontendEditing\Service; - /* * This file is part of the TYPO3 CMS project. * @@ -17,28 +15,30 @@ * The TYPO3 project - inspiring people to share! */ +namespace TYPO3\CMS\FrontendEditing\Utility; + + use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\VersionNumberUtility; /** - * Service class to get the settings from Extension Manager + * Convenience methods related to configuration */ -class ExtensionManagerConfigurationService +class ConfigurationUtility { /** - * Parse settings and return it as an array + * Returns the Extension Manager configuration array * - * @return array unserialized extconf settings + * @return array */ - public static function getSettings(): array + public static function getExtensionConfiguration(): array { - $settings = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('frontend_editing'); + $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('frontend_editing'); - if (!is_array($settings)) { - $settings = []; + if (is_array($configuration)) { + return $configuration; } - return $settings; + return []; } } From faabfc0e8c8774c1389f1843b5185fb3f0cbe4bf Mon Sep 17 00:00:00 2001 From: mabolek Date: Wed, 13 Jan 2021 13:41:16 +0100 Subject: [PATCH 37/37] [TASK] Trying to get all tests working --- Classes/Controller/EditorController.php | 3 +- .../FrontendEditingInitializationHook.php | 3 +- .../Service/ContentEditableWrapperService.php | 10 +- .../IsPlaceholderEnabledViewHelper.php | 3 +- .../EditingPanel/FrontendEditingPanelTest.php | 116 ++++++++---------- .../ContentEditableWrapperServiceTest.php | 89 +++++++++++--- ...tensionManagerConfigurationServiceTest.php | 14 ++- composer.json | 2 +- 8 files changed, 145 insertions(+), 95 deletions(-) diff --git a/Classes/Controller/EditorController.php b/Classes/Controller/EditorController.php index c2cc0ea2..8488aaf4 100644 --- a/Classes/Controller/EditorController.php +++ b/Classes/Controller/EditorController.php @@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; +use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility; /** * Class for fetching the proper RTE configuration of a given field @@ -153,7 +154,7 @@ protected function getExtraPlugins(): array $this->rteConfiguration['externalPlugins'] = []; } - if (ExtensionManagerConfigurationService::getSettings()['enablePlaceholders']) { + if (ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders']) { $this->rteConfiguration['externalPlugins']['confighelper'] = [ 'resource' => 'EXT:frontend_editing/Resources/Public/JavaScript/Plugins/confighelper/plugin.js' ]; diff --git a/Classes/Hook/FrontendEditingInitializationHook.php b/Classes/Hook/FrontendEditingInitializationHook.php index 1842315a..4613ae16 100644 --- a/Classes/Hook/FrontendEditingInitializationHook.php +++ b/Classes/Hook/FrontendEditingInitializationHook.php @@ -41,6 +41,7 @@ use TYPO3\CMS\FrontendEditing\Service\AccessService; use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService; use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; +use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility; use TYPO3\CMS\Lang\LanguageService as LanguageServiceTypo38; /** @@ -270,7 +271,7 @@ public function main(array $params, TypoScriptFrontendController $parentObject) window.F.setBESessionId(' . GeneralUtility::quoteJSvalue($this->getBeSessionKey()) . '); window.F.setTranslationLabels(' . json_encode($this->getLocalizedFrontendLabels()) . '); window.F.setDisableModalOnNewCe(' . - (int)ExtensionManagerConfigurationService::getSettings()['enablePlaceholders'] . + (int)ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders'] . '); window.FrontendEditingMode = true; window.TYPO3.settings = { diff --git a/Classes/Service/ContentEditableWrapperService.php b/Classes/Service/ContentEditableWrapperService.php index 90b0b3c5..92c961d4 100644 --- a/Classes/Service/ContentEditableWrapperService.php +++ b/Classes/Service/ContentEditableWrapperService.php @@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility; /** * A class for adding wrapping for a content element to be editable @@ -35,11 +36,6 @@ class ContentEditableWrapperService { const DEFAULT_WRAPPER_TAG_NAME = 'div'; - /** - * @var ExtensionManagerConfigurationService - */ - protected $extensionManagerConfigurationService; - /** * @var IconFactory */ @@ -60,10 +56,8 @@ class ContentEditableWrapperService */ public function __construct() { - $this->extensionManagerConfigurationService = - GeneralUtility::makeInstance(ExtensionManagerConfigurationService::class); $this->contentEditableWrapperTagName = self::DEFAULT_WRAPPER_TAG_NAME; - $tagName = $this->extensionManagerConfigurationService->getSettings()['contentEditableWrapperTagName']; + $tagName = ConfigurationUtility::getExtensionConfiguration()['contentEditableWrapperTagName']; if ($tagName) { $this->contentEditableWrapperTagName = $tagName; } diff --git a/Classes/ViewHelpers/IsPlaceholderEnabledViewHelper.php b/Classes/ViewHelpers/IsPlaceholderEnabledViewHelper.php index 18ff29a4..cbbac588 100644 --- a/Classes/ViewHelpers/IsPlaceholderEnabledViewHelper.php +++ b/Classes/ViewHelpers/IsPlaceholderEnabledViewHelper.php @@ -16,6 +16,7 @@ */ use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; +use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility; use TYPO3\CMS\FrontendEditing\Utility\FrontendEditingUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; @@ -47,6 +48,6 @@ public static function renderStatic( RenderingContextInterface $renderingContext ) { return FrontendEditingUtility::isEnabled() - && ExtensionManagerConfigurationService::getSettings()['enablePlaceholders']; + && ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders']; } } diff --git a/Tests/Unit/EditingPanel/FrontendEditingPanelTest.php b/Tests/Unit/EditingPanel/FrontendEditingPanelTest.php index 5e9f862f..66b395df 100644 --- a/Tests/Unit/EditingPanel/FrontendEditingPanelTest.php +++ b/Tests/Unit/EditingPanel/FrontendEditingPanelTest.php @@ -20,13 +20,19 @@ use TYPO3\CMS\Backend\FrontendBackendUserAuthentication; use TYPO3\CMS\Backend\Routing\Route; use TYPO3\CMS\Backend\Routing\Router; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Imaging\Icon; +use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures\PageRepositoryFixture; use TYPO3\CMS\FrontendEditing\EditingPanel\FrontendEditingPanel; +use TYPO3\CMS\FrontendEditing\Service\AccessService; use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService; -use TYPO3\CMS\Lang\LanguageService; +use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; +use TYPO3\CMS\Styleguide\TcaDataGenerator\TableHandler\General; /** * Test case for class TYPO3\CMS\FrontendEditing\EditingPanel\FrontendEditingPanel. @@ -35,7 +41,6 @@ */ class FrontendEditingPanelTest extends UnitTestCase { - /** * @var TemplateService */ @@ -51,6 +56,10 @@ class FrontendEditingPanelTest extends UnitTestCase */ protected function setUp() { + $accessServiceMock = $this->createMock(AccessService::class); + + $accessServiceMock->method('isEnabled')->willReturn(true); + $this->templateServiceMock = $this->getMockBuilder(TemplateService::class) ->setMethods(['getFileName', 'linkData'])->getMock(); @@ -72,6 +81,7 @@ protected function setUp() $this->frontendControllerMock->page = []; $this->frontendControllerMock->sys_page = $pageRepositoryMock; $GLOBALS['TSFE'] = $this->frontendControllerMock; + } /** @@ -81,36 +91,48 @@ protected function setUp() */ public function editIconsDataProvider() { - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $languageServiceMock = $this->createMock(LanguageService::class); + + $languageServiceMock + ->method('sL') + ->willReturnArgument(0); + + $GLOBALS['LANG'] = $languageServiceMock; - $router = GeneralUtility::makeInstance(Router::class); + $router = new Router(); $router->addRoute('record_edit', new Route('record_edit', [])); + GeneralUtility::setSingletonInstance(Router::class, $router); + + $iconMock = $this->createMock(Icon::class); + + $iconMock->method('render')->willReturn('zzz'); + + $iconFactoryMock = $this->getMockBuilder(IconFactory::class) + ->disableOriginalConstructor()->getMock() + ; + + $iconFactoryMock + ->method('getIcon') + ->willReturn($iconMock); + + GeneralUtility::addInstance(IconFactory::class, $iconFactoryMock); + + $extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class); + + $extensionConfigurationMock + ->method('get') + ->willReturn(['contentEditableWrapperTagName' => 'div']); + + GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock); $contentEditableWrapperService = new ContentEditableWrapperService(); $content = $this->getUniqueId('content'); + return [ 'standard case call edit icons for tt_content:bodytext' => [ - $contentEditableWrapperService->wrapContentWithDropzone( - 'tt_content', - 1, - $contentEditableWrapperService->wrapContent( - 'tt_content', - 1, - [], - $content - ) - ), - $contentEditableWrapperService->wrapContentWithDropzone( - 'tt_content', - 1, - $contentEditableWrapperService->wrapContent( - 'tt_content', - 1, - [], - $content - ) - ), + '', + '', 'tt_content:bodytext', ['beforeLastTag' => '1', 'allow' => 'edit'], 'tt_content:1', @@ -123,28 +145,8 @@ public function editIconsDataProvider() 1 ], 'another case with fe_users:email' => [ - $contentEditableWrapperService->wrapContentWithDropzone( - 'fe_users', - 12, - $contentEditableWrapperService->wrapContent( - 'fe_users', - 12, - [], - '
' - . $content . '
' - ) - ), - $contentEditableWrapperService->wrapContentWithDropzone( - 'fe_users', - 12, - $contentEditableWrapperService->wrapContent( - 'fe_users', - 12, - [], - '
' - . $content . '
' - ) - ), + '', + '', 'fe_users:email', ['beforeLastTag' => '1', 'allow' => 'edit'], 'fe_users:12', @@ -157,26 +159,8 @@ public function editIconsDataProvider() 1 ], 'another case with tt_content:header' => [ - $contentEditableWrapperService->wrapContentWithDropzone( - 'tt_content', - 12, - $contentEditableWrapperService->wrapContent( - 'tt_content', - 12, - [], - $content - ) - ), - $contentEditableWrapperService->wrapContentWithDropzone( - 'tt_content', - 12, - $contentEditableWrapperService->wrapContent( - 'tt_content', - 12, - [], - $content - ) - ), + '', + '', 'tt_content:header', ['beforeLastTag' => '1', 'allow' => 'edit'], 'tt_content:12', diff --git a/Tests/Unit/Service/ContentEditableWrapperServiceTest.php b/Tests/Unit/Service/ContentEditableWrapperServiceTest.php index d3d21670..c5e1772b 100644 --- a/Tests/Unit/Service/ContentEditableWrapperServiceTest.php +++ b/Tests/Unit/Service/ContentEditableWrapperServiceTest.php @@ -17,8 +17,12 @@ */ use Nimut\TestingFramework\TestCase\UnitTestCase; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService; +use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; use TYPO3\CMS\FrontendEditing\Tests\Unit\Fixtures\ContentEditableFixtures; /** @@ -43,31 +47,83 @@ class ContentEditableWrapperServiceTest extends UnitTestCase */ protected function setUp() { - Bootstrap::getInstance()->initializeBackendRouter(); + parent::setUp(); + + $languageServiceMock = $this->createMock(LanguageService::class); + + $languageServiceMock + ->method('sL') + ->willReturnArgument(0); + + $GLOBALS['LANG'] = $languageServiceMock; + + $extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class); + + $extensionConfigurationMock + ->method('get') + ->willReturn([]); + + GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock); + $this->subject = new ContentEditableWrapperService(); - $this->fixtures = new ContentEditableFixtures(); } protected function tearDown() { unset($this->subject); + unset($GLOBALS['TCA']); } /** + * Data provider for getWrappedContent() + * + * @return array[] + */ + public function getWrappedContentDataProvider() + { + $content = $this->getUniqueId('content'); + + return [ + 'normal content' => [ + '', + 'tablename', + 'fieldname', + 123, + $content, + [ + 'columns' => [ + 'label' => 'Field label' + ] + ] + ] + ]; + } + + /** + * @dataProvider getWrappedContentDataProvider * @test */ - public function getWrappedContent() + public function getWrappedContent( + string $expected, + string $table, + string $field, + int $uid, + string $content, + array $tableTca + ) { + $GLOBALS['TCA'][$table] = $tableTca; + $wrappedContent = $this->subject->wrapContentToBeEditable( - $this->fixtures->getTable(), - $this->fixtures->getField(), - $this->fixtures->getUid(), - $this->fixtures->getContent() + $table, + $field, + $uid, + $content ); - self::assertSame( + $this->assertSame( $wrappedContent, - $this->fixtures->getWrappedExpectedContent() + $expected ); } @@ -83,7 +139,7 @@ public function getWrapContent() $this->fixtures->getContent() ); - self::assertSame( + $this->assertSame( $wrapContent, $this->fixtures->getWrapExpectedContent() ); @@ -99,7 +155,8 @@ public function getWrapContentWithDropzone() $this->fixtures->getUid(), $this->fixtures->getContent() ); - self::assertSame( + + $this->assertSame( $wrapContent, $this->fixtures->getWrapWithDropzoneExpectedContent() ); @@ -118,7 +175,7 @@ public function tryWrapContentAndExpectAnException() $this->fixtures->getContent() ); } catch (\Exception $exception) { - self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } self::fail('Expected Property "table" missing Exception has not been raised.'); @@ -137,7 +194,7 @@ public function tryWrapContentAndExpectAnExceptionForMissingTable() $this->fixtures->getContent() ); } catch (\Exception $exception) { - self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } self::fail('Expected Property "table" missing Exception has not been raised.'); @@ -156,7 +213,7 @@ public function tryWrapContentAndExpectAnExceptionForMissingUid() $this->fixtures->getContent() ); } catch (\Exception $exception) { - self::assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!'); + $this->assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!'); return; } self::fail('Expected Property "uid" missing Exception has not been raised.'); @@ -173,7 +230,7 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingTable() $this->fixtures->getContent() ); } catch (\Exception $exception) { - self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); + $this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!'); return; } self::fail('Expected Property "table" missing Exception has not been raised.'); @@ -191,7 +248,7 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingUid() $this->fixtures->getContent() ); } catch (\Exception $exception) { - self::assertEquals($exception->getMessage(), 'Property "uid" is not valid!'); + $this->assertEquals($exception->getMessage(), 'Property "uid" is not valid!'); return; } self::fail('Expected Property "uid" missing Exception has not been raised.'); diff --git a/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php b/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php index 97bb638f..e6560e6b 100644 --- a/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php +++ b/Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php @@ -17,7 +17,11 @@ */ use Nimut\TestingFramework\TestCase\UnitTestCase; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService; +use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility; +use TYPO3\CMS\Styleguide\TcaDataGenerator\TableHandler\General; /** * Test case for class TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService. @@ -31,8 +35,16 @@ class ExtensionManagerConfigurationServiceTest extends UnitTestCase */ public function getExtensionManagerSettings() { + $extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class); + + $extensionConfigurationMock + ->method('get') + ->willReturn([]); + + GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock); + self::assertSame( - ExtensionManagerConfigurationService::getSettings(), + ConfigurationUtility::getExtensionConfiguration(), [] ); } diff --git a/composer.json b/composer.json index 1aa001a4..9848e515 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no", "ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/", "ci:tests:unit": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit", - "ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'", + "ci:tests:functional": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml Tests/Functional", "ci:tests": [ "@ci:tests:unit", "@ci:tests:functional"