Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[TASK] Add compatibility with TYPO3 v12 #31

Merged
merged 14 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ on:
- cron: '30 3 * * *'

jobs:

tests:
name: All tests
runs-on: ubuntu-20.04
strategy:
matrix:
php: [ '8.1', '8.2']
TYPO3: [ '11', '12']
include:
- TYPO3: 12
PHP: 8.3
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down
73 changes: 38 additions & 35 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#

# Function to write a .env file in Build/testing-docker
# This is read by docker-compose and vars defined here are
# This is read by "docker compose" and vars defined here are
# used in Build/testing-docker/docker-compose.yml
setUpDockerComposeDotEnv() {
# Delete possibly existing local .env file if exists
Expand All @@ -14,7 +14,7 @@ setUpDockerComposeDotEnv() {
{
echo "COMPOSE_PROJECT_NAME=local"
# To prevent access rights of files created by the testing, the docker image later
# runs with the same user that is currently executing the script. docker-compose can't
# runs with the same user that is currently executing the script. "docker compose" can't
# use $UID directly itself since it is a shell variable and not an env variable, so
# we have to set it explicitly here.
echo "HOST_UID=`id -u`"
Expand All @@ -24,10 +24,10 @@ setUpDockerComposeDotEnv() {
# Your local user
echo "HOST_USER=${USER}"
echo "TEST_FILE=${TEST_FILE}"
echo "TYPO3_VERSION=${TYPO3_VERSION}"
echo "PHP_XDEBUG_ON=${PHP_XDEBUG_ON}"
echo "PHP_XDEBUG_PORT=${PHP_XDEBUG_PORT}"
echo "DOCKER_PHP_IMAGE=${DOCKER_PHP_IMAGE}"
echo "TYPO3=${TYPO3}"
echo "PHP_VERSION=${PHP_VERSION}"
echo "EXTRA_TEST_OPTIONS=${EXTRA_TEST_OPTIONS}"
echo "SCRIPT_VERBOSE=${SCRIPT_VERBOSE}"
Expand All @@ -44,7 +44,7 @@ Successfully tested with docker version 18.06.1-ce and docker-compose 1.21.2.

Usage: $0 [options] [file]

No arguments: Run all unit tests with PHP 7.4
No arguments: Run all unit tests with PHP 8.0

Options:
-s <...>
Expand All @@ -58,7 +58,7 @@ Options:
- phpstan: phpstan analyze
- unit (default): PHP unit tests

-t <10|11>
-t <11|12>
Only with -s composerUpdate|acceptance|functional
TYPO3 core major version the extension is embedded in for testing.

Expand All @@ -69,9 +69,9 @@ Options:
- postgres: use postgres
- sqlite: use sqlite

-p <7.2|7.3|7.4|8.0|8.1|8.2>
-p <8.0|8.1|8.|8.3>
Specifies the PHP minor version to be used
- 7.4 (default): use PHP 7.4
- 8.0 (default): use PHP 8.0

-e "<phpunit or codeception options>"
Only with -s acceptance|functional|unit
Expand Down Expand Up @@ -107,16 +107,16 @@ Options:
Show this help.

Examples:
# Run unit tests using PHP 7.4
# Run unit tests using PHP 8.0
./Build/Scripts/runTests.sh

# Run unit tests using PHP 7.3
./Build/Scripts/runTests.sh -p 7.3
# Run unit tests using PHP 8.1
./Build/Scripts/runTests.sh -p 8.1
EOF

# Test if docker-compose exists, else exit out with error
if ! type "docker-compose" > /dev/null; then
echo "This script relies on docker and docker-compose. Please install" >&2
if ! type "docker" > /dev/null; then
echo "This script relies on docker. Please install" >&2
exit 1
fi

Expand All @@ -139,13 +139,13 @@ fi
# Option defaults
TEST_SUITE="unit"
DBMS="mariadb"
PHP_VERSION="7.4"
PHP_VERSION="8.0"
TYPO3_VERSION="11"
PHP_XDEBUG_ON=0
PHP_XDEBUG_PORT=9003
EXTRA_TEST_OPTIONS=""
SCRIPT_VERBOSE=0
CGLCHECK_DRY_RUN=""
TYPO3="10"

# Option parsing
# Reset in case getopts has been used previously in the shell
Expand All @@ -163,12 +163,15 @@ while getopts ":s:d:p:e:t:xy:nhuv" OPT; do
;;
p)
PHP_VERSION=${OPTARG}
if ! [[ ${PHP_VERSION} =~ ^(7.2|7.3|7.4|8.0|8.1|8.2)$ ]]; then
if ! [[ ${PHP_VERSION} =~ ^(8.0|8.1|8.2|8.3)$ ]]; then
INVALID_OPTIONS+=("${OPTARG}")
fi
;;
t)
TYPO3=${OPTARG}
TYPO3_VERSION=${OPTARG}
if ! [[ ${TYPO3_VERSION} =~ ^(11|12)$ ]]; then
INVALID_OPTIONS+=("p ${OPTARG}")
fi
;;
e)
EXTRA_TEST_OPTIONS=${OPTARG}
Expand Down Expand Up @@ -212,7 +215,7 @@ if [ ${#INVALID_OPTIONS[@]} -ne 0 ]; then
exit 1
fi

# Move "7.4" to "php74", the latter is the docker container name
# Move "8.0" to "php80", the latter is the docker container name
DOCKER_PHP_IMAGE=$(echo "php${PHP_VERSION}" | sed -e 's/\.//')

# Set $1 to first mass argument, this is the optional test file or test directory to execute
Expand All @@ -230,46 +233,46 @@ fi
case ${TEST_SUITE} in
acceptance)
setUpDockerComposeDotEnv
docker-compose run acceptance_backend_mariadb10
docker compose run acceptance_backend_mariadb10
SUITE_EXIT_CODE=$?
docker-compose down
#docker compose down
;;
cgl)
# Active dry-run for cgl needs not "-n" but specific options
if [ -n "${CGLCHECK_DRY_RUN}" ]; then
CGLCHECK_DRY_RUN="--dry-run --diff"
fi
setUpDockerComposeDotEnv
docker-compose run cgl
docker compose run cgl
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerUpdate)
setUpDockerComposeDotEnv
docker-compose run composer_update
docker compose run composer_update
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerValidate)
setUpDockerComposeDotEnv
docker-compose run composer_validate
docker compose run composer_validate
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
mariadb)
docker-compose run functional_mariadb10
docker compose run functional_mariadb10
SUITE_EXIT_CODE=$?
;;
postgres)
docker-compose run functional_postgres10
docker compose run functional_postgres10
SUITE_EXIT_CODE=$?
;;
sqlite)
mkdir -p ${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/
docker-compose run functional_sqlite
docker compose run functional_sqlite
SUITE_EXIT_CODE=$?
;;
*)
Expand All @@ -278,25 +281,25 @@ case ${TEST_SUITE} in
echo "${HELP}" >&2
exit 1
esac
docker-compose down
docker compose down
;;
lint)
setUpDockerComposeDotEnv
docker-compose run lint
docker compose run lint
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
phpstan)
setUpDockerComposeDotEnv
docker-compose run phpstan
docker compose run phpstan
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
unit)
setUpDockerComposeDotEnv
docker-compose run unit
docker compose run unit
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
update)
# pull typo3/core-testing-*:latest versions of those ones that exist locally
Expand Down
59 changes: 58 additions & 1 deletion Build/php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
<?php

$config = \TYPO3\CodingStandards\CsFixerConfig::create();
$config->getFinder()->exclude(['var']);
$config->getFinder()->in('./')->exclude(['var', '.Build']);

$config->setRules([
'@DoctrineAnnotation' => true,
'@PER-CS' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_opening_tag' => true,
'braces' => ['allow_single_line_closure' => true],
'cast_spaces' => ['space' => 'none'],
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'type_declaration_spaces' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'new_with_parentheses' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_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' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => ['assertions' => ['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,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
]);

return $config;
20 changes: 20 additions & 0 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
parameters:
ignoreErrors:
-
message: "#^Call to method getDataStructure\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\Event\\\\AfterFlexFormDataStructureParsedEvent\\.$#"
count: 1
path: ../Classes/Backend/EventListener/FlexFormParsingModifyEventListener.php

-
message: "#^Call to method getIdentifier\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\Event\\\\AfterFlexFormDataStructureParsedEvent\\.$#"
count: 1
path: ../Classes/Backend/EventListener/FlexFormParsingModifyEventListener.php

-
message: "#^Call to method setDataStructure\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\Event\\\\AfterFlexFormDataStructureParsedEvent\\.$#"
count: 1
path: ../Classes/Backend/EventListener/FlexFormParsingModifyEventListener.php

-
message: "#^Parameter \\$event of method B13\\\\FormCustomTemplates\\\\Backend\\\\EventListener\\\\FlexFormParsingModifyEventListener\\:\\:modifyDataStructure\\(\\) has invalid type TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\Event\\\\AfterFlexFormDataStructureParsedEvent\\.$#"
count: 1
path: ../Classes/Backend/EventListener/FlexFormParsingModifyEventListener.php

-
message: "#^Parameter \\$event of method B13\\\\FormCustomTemplates\\\\Backend\\\\EventListener\\\\ModifyButtonBarEventListener\\:\\:__invoke\\(\\) has invalid type TYPO3\\\\CMS\\\\Backend\\\\Template\\\\Components\\\\ModifyButtonBarEvent\\.$#"
count: 1
Expand Down
30 changes: 13 additions & 17 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '2.3'
services:
chrome:
# Image for Mac M1
Expand Down Expand Up @@ -47,6 +46,8 @@ services:
php -S web:8000 -t ${CORE_ROOT}/.Build/Web
fi
"
ports:
- "8000:8000"

acceptance_backend_mariadb10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
Expand Down Expand Up @@ -78,7 +79,7 @@ services:
echo Database is up;
php -v | grep '^PHP';
mkdir -p Web/typo3temp/var/tests/
COMMAND=\"vendor/codeception/codeception/codecept run Backend -d -c Web/typo3conf/ext/form_custom_templates/Tests/codeception.yml ${TEST_FILE}\"
COMMAND=\"vendor/codeception/codeception/codecept run Backend -d -c ../Tests/codeception.yml ${TEST_FILE}\"
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
$${COMMAND};
Expand Down Expand Up @@ -106,25 +107,12 @@ services:
set -x
fi
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
php -dxdebug.mode=off \
.Build/bin/php-cs-fixer fix \
-v \
${CGLCHECK_DRY_RUN} \
--config=Build/php-cs-fixer.php \
--using-cache=no .
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
PHP_CS_FIXER_ALLOW_XDEBUG=1 \
.Build/bin/php-cs-fixer fix \
-v \
${CGLCHECK_DRY_RUN} \
--config=Build/php-cs-fixer.php \
--using-cache=no .
fi
.Build/bin/php-cs-fixer fix -v --config=Build/php-cs-fixer.php --using-cache=no .
"

composer_update:
Expand All @@ -142,7 +130,15 @@ services:
set -x
fi
php -v | grep '^PHP';
COMPOSER_HOME=${CORE_ROOT}/.Build/.composer composer update --no-progress --no-interaction;
if [ ${TYPO3_VERSION} -eq 11 ]; then
composer req --dev --no-update typo3/cms-composer-installers:^3.0
composer req typo3/cms-core:^11.5 typo3/cms-recordlist:^11.5 --no-update
fi
if [ ${TYPO3_VERSION} -eq 12 ]; then
composer req --dev --no-update "typo3/cms-composer-installers:^5.0"
composer req typo3/cms-core:^12.4 --no-update
fi
composer update --no-progress --no-interaction;
"

composer_validate:
Expand Down
Loading