diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ab47261..1b1a91f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,11 +15,10 @@ jobs: strategy: matrix: php-version: - - 7.2 - - 7.3 - 7.4 - 8.0 - 8.1 + - 8.2 steps: - name: Checkout uses: actions/checkout@v3 @@ -87,10 +86,6 @@ jobs: strategy: matrix: include: - - php-version: '7.2' - typo3-version: '^10.4' - - php-version: '7.3' - typo3-version: '^10.4' - php-version: '7.4' typo3-version: '^10.4' - php-version: '7.4' @@ -99,6 +94,8 @@ jobs: typo3-version: '^11.5' - php-version: '8.1' typo3-version: '^11.5' + - php-version: '8.2' + typo3-version: '^11.5' steps: - uses: actions/checkout@v3 @@ -109,7 +106,9 @@ jobs: tools: composer:v2 - name: Install dependencies with expected TYPO3 version - run: composer require --no-interaction --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}" "typo3/cms-fluid-styled-content:${{ matrix.typo3-version }}" + run: |- + composer require --no-interaction --prefer-dist --no-progress "typo3/cms-backend:${{ matrix.typo3-version }}" "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}" "typo3/cms-fluid-styled-content:${{ matrix.typo3-version }}" + ./vendor/bin/codecept build - name: Code Quality (by PHPStan) run: ./vendor/bin/phpstan analyse @@ -122,12 +121,6 @@ jobs: strategy: matrix: include: - - php-version: '7.2' - typo3-version: '^10.4' - db-version: '5.6' - - php-version: '7.3' - typo3-version: '^10.4' - db-version: '5.6' - php-version: '7.4' typo3-version: '^10.4' db-version: '5.6' @@ -143,6 +136,9 @@ jobs: - php-version: '8.1' typo3-version: '^11.5' db-version: '8' + - php-version: '8.2' + typo3-version: '^11.5' + db-version: '8' steps: - uses: actions/checkout@v3 @@ -170,3 +166,15 @@ jobs: export typo3DatabaseUsername="root" export typo3DatabasePassword="root" ./vendor/bin/phpunit --testdox + + tests-acceptance: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v17 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Run Acceptance Tests + run: nix-shell --run project-test-acceptance diff --git a/Documentation/Changelog/2.0.0.rst b/Documentation/Changelog/2.0.0.rst index c52493e..4e8a036 100644 --- a/Documentation/Changelog/2.0.0.rst +++ b/Documentation/Changelog/2.0.0.rst @@ -1,4 +1,4 @@ -1.3.0 +2.0.0 ===== Breaking @@ -8,10 +8,12 @@ Breaking The modules got new identifiers. User permissions need to be adjusted. An update wizard is provided that will migrate the permissions. +* Drop support for PHP 7.2 + 7.3. + Features -------- -* Add support for TYPO3 v11 and PHP 8.0 + 8.1. +* Add support for TYPO3 v11 and PHP 8.0 + 8.1 + 8.2. * Last import date is now shown within backend module beside each import configuration. @@ -108,6 +110,8 @@ Tasks Provide new icon for storage folders. Provide new icon for content element. +* Add first acceptance tests for backend modules. + Deprecation ----------- diff --git a/Tests/Acceptance/BackendConfigurationCest.php b/Tests/Acceptance/BackendConfigurationCest.php new file mode 100644 index 0000000..2b302a4 --- /dev/null +++ b/Tests/Acceptance/BackendConfigurationCest.php @@ -0,0 +1,70 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +namespace WerkraumMedia\ThueCat\Tests\Acceptance; + +use WerkraumMedia\ThueCat\Tests\Acceptance\Support\AcceptanceTester; + +class BackendConfigurationCest +{ + public function _before(AcceptanceTester $I): void + { + $I->amOnPage('/typo3'); + $I->submitForm('#typo3-login-form', [ + 'username' => 'admin', + 'p_field' => 'password', + ]); + $I->waitForText('New TYPO3 site'); + } + + public function showsIndex(AcceptanceTester $I): void + { + $I->click('Configurations'); + $I->switchToContentFrame(); + $I->see('ThüCAT - Configurations'); + $I->see('Example Configuration'); + $I->see('Please provide an import configuration and trigger import to create an organisation.'); + } + + public function allowsToImportExistingConfiguration(AcceptanceTester $I): void + { + $I->click('Configurations'); + $I->switchToContentFrame(); + $I->see('Example Configuration'); + $I->see('Never'); + $I->click('Import based on import configuration'); + + $I->see('Import finished'); + $I->see('Imported configuration "Example Configuration".'); + $I->see('Tourist-Information Schmalkalden'); + } + + public function showsExecutedImport(AcceptanceTester $I): void + { + $I->click('Imports'); + $I->switchToContentFrame(); + $I->see('ThüCAT - Imports'); + + $I->see('Example Configuration'); + } +} diff --git a/Tests/Acceptance/Data/.gitkeep b/Tests/Acceptance/Data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Acceptance/Data/BasicDatabase.csv b/Tests/Acceptance/Data/BasicDatabase.csv new file mode 100644 index 0000000..d99b3ad --- /dev/null +++ b/Tests/Acceptance/Data/BasicDatabase.csv @@ -0,0 +1,45 @@ +pages +,uid,pid,doktype,slug,title +,1,0,4,/,Rootpage +,2,1,255,/storage,Storage +tx_thuecat_import_configuration +,uid,pid,title,type,configuration +,1,2,"Example Configuration",static," + + + + + 2 + + + + + + + + https://thuecat.org/resources/644315157726-jmww + + + + 0 + + + + + + https://thuecat.org/resources/072778761562-kwah + + + + 0 + + + + + + +", +"be_users" +,"uid","pid","tstamp","username","password","admin","disable","starttime","endtime","options","crdate","workspace_perms","deleted","TSconfig","lastlogin","workspace_id","db_mountpoints","usergroup","realName" +# password is "password" +,1,0,1366642540,"admin","$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1",1,0,0,0,0,1366642540,1,0,,1371033743,0,0,0,"Klaus Admin" diff --git a/Tests/Acceptance/Data/Sites/default/config.yaml b/Tests/Acceptance/Data/Sites/default/config.yaml new file mode 100644 index 0000000..f33946f --- /dev/null +++ b/Tests/Acceptance/Data/Sites/default/config.yaml @@ -0,0 +1,47 @@ +base: 'http://localhost:8080' +languages: + - + title: Deutsch + enabled: true + base: / + typo3Language: de + locale: de_DE.UTF-8 + iso-639-1: de + navigationTitle: Deutsch + hreflang: de-DE + direction: '' + flag: de + websiteTitle: '' + languageId: 0 + - + title: English + enabled: true + base: /en + typo3Language: default + locale: en_GB.UTF-8 + iso-639-1: en + websiteTitle: '' + navigationTitle: English + hreflang: en-GB + direction: '' + flag: gb + languageId: 1 + fallbackType: strict + fallbacks: '0' + - + title: French + enabled: true + base: /fr/ + typo3Language: fr + locale: fr_FR.ytf8 + iso-639-1: fr + websiteTitle: '' + navigationTitle: '' + hreflang: fr-FR + direction: '' + fallbackType: strict + fallbacks: '1,0' + flag: fr + languageId: 2 +rootPageId: 1 +websiteTitle: 'Example Website' diff --git a/Tests/Acceptance/Support/AcceptanceTester.php b/Tests/Acceptance/Support/AcceptanceTester.php new file mode 100644 index 0000000..8ac78d2 --- /dev/null +++ b/Tests/Acceptance/Support/AcceptanceTester.php @@ -0,0 +1,53 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +namespace WerkraumMedia\ThueCat\Tests\Acceptance\Support; + +use Codeception\Actor; +use TYPO3\TestingFramework\Core\Acceptance\Step\FrameSteps; +use WerkraumMedia\ThueCat\Tests\Acceptance\Support\_generated\AcceptanceTesterActions; + +/** + * Inherited Methods + * @method void wantToTest($text) + * @method void wantTo($text) + * @method void execute($callable) + * @method void expectTo($prediction) + * @method void expect($prediction) + * @method void amGoingTo($argumentation) + * @method void am($role) + * @method void lookForwardTo($achieveValue) + * @method void comment($description) + * @method void pause() + * + * @SuppressWarnings(PHPMD) +*/ +class AcceptanceTester extends Actor +{ + use FrameSteps; + use AcceptanceTesterActions; + + /** + * Define custom actions here + */ +} diff --git a/Tests/Acceptance/Support/Environment.php b/Tests/Acceptance/Support/Environment.php new file mode 100644 index 0000000..59433ba --- /dev/null +++ b/Tests/Acceptance/Support/Environment.php @@ -0,0 +1,52 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +namespace WerkraumMedia\ThueCat\Tests\Acceptance\Support; + +use TYPO3\TestingFramework\Core\Acceptance\Extension\BackendEnvironment; + +/** + * Load various core extensions and extension under test. + */ +class Environment extends BackendEnvironment +{ + protected $localConfig = [ + 'coreExtensionsToLoad' => [ + 'install', + 'core', + 'backend', + 'extbase', + 'frontend', + 'fluid', + ], + 'testExtensionsToLoad' => [ + 'typo3conf/ext/thuecat', + ], + 'csvDatabaseFixtures' => [ + __DIR__ . '/../Data/BasicDatabase.csv', + ], + 'pathsToLinkInTestInstance' => [ + '/../../../../../../Tests/Acceptance/Data/Sites/' => 'typo3conf/sites', + ], + ]; +} diff --git a/Tests/Acceptance/Support/_generated/.gitignore b/Tests/Acceptance/Support/_generated/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/Tests/Acceptance/Support/_generated/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/Tests/Acceptance/_output/.gitignore b/Tests/Acceptance/_output/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/Tests/Acceptance/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/codeception.dist.yml b/codeception.dist.yml new file mode 100644 index 0000000..f9f7b80 --- /dev/null +++ b/codeception.dist.yml @@ -0,0 +1,44 @@ +namespace: 'WerkraumMedia\ThueCat\Tests\Acceptance\Support' + +paths: + tests: 'Tests/Acceptance' + data: 'Tests/Acceptance/Data' + output: '.Build/web/typo3temp/var/tests/AcceptanceReports' + support: 'Tests/Acceptance/Support' + +settings: + debug: true + +extensions: + enabled: + - 'Codeception\Extension\RunFailed' + +suites: + acceptance: + actor: 'AcceptanceTester' + path: . + extensions: + enabled: + - 'Codeception\Extension\RunProcess': + - 'geckodriver > .Build/web/typo3temp/var/tests/AcceptanceReports/geckodriver.log 2>&1' + - 'TYPO3_PATH_APP="$INSTANCE_PATH" TYPO3_PATH_ROOT="$INSTANCE_PATH" php -S 127.0.0.1:8080 -t "$INSTANCE_PATH" > .Build/web/typo3temp/var/tests/AcceptanceReports/php.log 2>&1' + - 'WerkraumMedia\ThueCat\Tests\Acceptance\Support\Environment': + 'typo3DatabaseUsername': 'testing' + 'typo3DatabasePassword': 'testing' + + modules: + enabled: + - WebDriver: + url: 'http://localhost:8080' + browser: 'firefox' + restart: true + path: '' + wait: 5 + capabilities: + moz:firefoxOptions: + args: + - '-headless' + - '\TYPO3\TestingFramework\Core\Acceptance\Helper\Acceptance' + step_decorators: + - 'Codeception\Step\Retry' + diff --git a/composer.json b/composer.json index 8372805..ba129f4 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ } }, "require": { - "php": "~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0", + "php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", "ext-json": "*", "ext-mbstring": "*", "psr/http-client": "^1.0", @@ -54,6 +54,8 @@ "typo3/cms-frontend": "^10.4 || ^11.5" }, "require-dev": { + "codeception/codeception": "^4.2", + "codeception/module-webdriver": "^2.0", "jangregor/phpstan-prophecy": "^1.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "1.1.0", diff --git a/phpstan.neon b/phpstan.neon index b33b687..ca2e558 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,6 +6,8 @@ parameters: - Classes - Configuration - Tests + excludePaths: + - Tests/Acceptance/Support/_generated/ checkMissingIterableValueType: false reportUnmatchedIgnoredErrors: false checkGenericClassInNonGenericObjectType: false diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..93976bb --- /dev/null +++ b/shell.nix @@ -0,0 +1,43 @@ +{ pkgs ? import { } }: + +let + projectInstall = pkgs.writeShellApplication { + name = "project-install"; + runtimeInputs = [ + pkgs.php82 + pkgs.php82Packages.composer + ]; + text = '' + composer install --prefer-dist --no-progress --working-dir="$PROJECT_ROOT" + ''; + }; + projectTestAcceptance = pkgs.writeShellApplication { + name = "project-test-acceptance"; + runtimeInputs = [ + projectInstall + pkgs.sqlite + pkgs.firefox + pkgs.geckodriver + pkgs.php82 + ]; + text = '' + project-install + + export INSTANCE_PATH="$PROJECT_ROOT/.Build/web/typo3temp/var/tests/acceptance" + export typo3DatabaseDriver=pdo_sqlite + + mkdir -p "$INSTANCE_PATH" + ./vendor/bin/codecept run + ''; + }; + +in pkgs.mkShell { + name = "TYPO3 Extension ThüCAT"; + buildInputs = [ + projectTestAcceptance + ]; + + shellHook = '' + export PROJECT_ROOT="$(pwd)" + ''; +}