netresearch/typo3-testing-skill / skills/typo3-testing
typo3-testing
FlaggedUse when reproducing defects as failing tests, testing template or rendered output changes, confirming changes on a running TYPO3 instance, or setting up TYPO3 extension tests: unit/functional/E2E, PHPUnit 11-13, mutation testing, final-class mocks (v14), CI matrix across TYPO3 12/13/14.3 LTS, typo3-ci-workflows meta-package, CI failures. Also: transaction rollback, worker crashes, competing requests, testing-framework setup, test matrix, integration/e2e testing, coverage, test generation.
assets/Build/Scripts/runTests.sh
View on GitHub#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Derived from Build/Scripts/runTests.sh of TYPO3 CMS Core
# (https://github.com/TYPO3/typo3), which is licensed GPL-2.0-or-later;
# this adaptation is distributed under the same licence.
#
# ShellCheck SC2086 is disabled for the whole file: CONTAINER_COMMON_PARAMS,
# CI_PARAMS, XDEBUG_MODE and CONTAINERPARAMS each hold several options and
# are split into words on purpose, as in TYPO3 Core's runner. Every other
# expansion that ends up on a command line is quoted.
# shellcheck disable=SC2086
#
# TYPO3 Extension Test Runner
# Docker/podman-based test orchestration following TYPO3 core conventions.
#
# Template from: https://github.com/netresearch/typo3-testing-skill
# Reference: https://github.com/netresearch/t3x-nr-vault
#
# CUSTOMIZATION REQUIRED:
# 1. Replace 'my-extension' in NETWORK variable with your extension key
# 2. Set COMPOSER_ROOT_VERSION to your extension version
# 3. Adjust TYPO3_BASE_URL default for E2E tests
# 4. Remove mock OAuth section if not needed
#
trap 'cleanUp;exit 2' SIGINT
waitFor() {
local HOST=${1}
local PORT=${2}
local TESTCOMMAND="
COUNT=0;
while ! nc -z ${HOST} ${PORT}; do
if [ \"\${COUNT}\" -gt 10 ]; then
echo \"Can not connect to ${HOST} port ${PORT}. Aborting.\";
exit 1;
fi;
sleep 1;
COUNT=\$((COUNT + 1));
done;
"
if ! "${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "wait-for-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" "${IMAGE_ALPINE}" /bin/sh -c "${TESTCOMMAND}"; then
kill -SIGINT -$$
fi
}
# Not called by the suites below; kept for suites that start an HTTP service
# (see references/test-runners.md, "waitForHttp").
# ShellCheck before 0.11 reports this as SC2317 (unreachable), 0.11 as SC2329.
# shellcheck disable=SC2317,SC2329
waitForHttp() {
local URL=${1}
local MAX_ATTEMPTS=${2:-30}
local TESTCOMMAND="
COUNT=0;
while ! wget -q --spider ${URL} 2>/dev/null; do
if [ \"\${COUNT}\" -gt ${MAX_ATTEMPTS} ]; then
echo \"HTTP endpoint ${URL} not available after ${MAX_ATTEMPTS} attempts. Aborting.\";
exit 1;
fi;
sleep 1;
COUNT=\$((COUNT + 1));
done;
echo \"HTTP endpoint ${URL} is ready.\";
"
if ! "${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "wait-for-http-${SUFFIX}" "${IMAGE_ALPINE}" /bin/sh -c "${TESTCOMMAND}"; then
kill -SIGINT -$$
fi
}
cleanUp() {
ATTACHED_CONTAINERS=$("${CONTAINER_BIN}" ps --filter "network=${NETWORK}" --format='{{.Names}}' 2>/dev/null)
for ATTACHED_CONTAINER in ${ATTACHED_CONTAINERS}; do
"${CONTAINER_BIN}" rm -f "${ATTACHED_CONTAINER}" >/dev/null 2>&1
done
"${CONTAINER_BIN}" network rm "${NETWORK}" >/dev/null 2>&1
}
cleanCacheFiles() {
echo -n "Clean caches ... "
rm -rf \
.Build/.cache \
.php-cs-fixer.cache \
Tests/Build/.phpunit.cache
echo "done"
}
handleDbmsOptions() {
case ${DBMS} in
mariadb)
[ -z "${DATABASE_DRIVER}" ] && DATABASE_DRIVER="mysqli"
if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then
echo "Invalid combination -d ${DBMS} -a ${DATABASE_DRIVER}" >&2
exit 1
fi
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="11.8"
# MariaDB series still in community support (mariadb.org
# maintenance policy): 10.11 until 2028-02, 11.4 until 2029-05,
# 11.8 until 2028-06, 12.3 until 2029-06. 10.5, 10.6 and 11.0 are
# EOL; 12.0-12.2 are rolling releases, not LTS, and Docker Hub
# stopped rebuilding 12.2 in May 2026.
#
# A version that has left support is mapped onto the LTS of its own
# series rather than refused: `-i 10.5` sits in Makefiles, READMEs
# and muscle memory across every consumer, and failing those calls
# buys nothing. The substitution is announced on every run, because
# a test that silently ran a different engine than it was asked for
# is worse than a broken call. To run the requested version anyway
# — reproducing a customer's bug on their engine — set
# DBMS_VERSION_EXACT=1, which skips both the mapping and the check.
if [ "${DBMS_VERSION_EXACT:-0}" != "1" ]; then
case "${DBMS_VERSION}" in
10.5|10.6) DBMS_VERSION_LTS="10.11" ;;
11.0|11.1|11.2|11.3) DBMS_VERSION_LTS="11.4" ;;
11.5|11.6|11.7) DBMS_VERSION_LTS="11.8" ;;
12.0|12.1|12.2) DBMS_VERSION_LTS="12.3" ;;
*) DBMS_VERSION_LTS="" ;;
esac
if [ -n "${DBMS_VERSION_LTS}" ]; then
echo "WARNING: MariaDB ${DBMS_VERSION} is out of support (EOL, or a rolling release)." >&2
echo " Running ${DBMS_VERSION_LTS} instead — the supported series it belongs to." >&2
echo " Set DBMS_VERSION_EXACT=1 to run ${DBMS_VERSION} anyway." >&2
DBMS_VERSION="${DBMS_VERSION_LTS}"
fi
if ! [[ ${DBMS_VERSION} =~ ^(10.11|11.4|11.8|12.3)$ ]]; then
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
echo "Supported: 10.11, 11.4, 11.8, 12.3. Set DBMS_VERSION_EXACT=1 to run an unsupported version." >&2
exit 1
fi
fi
;;
mysql)
[ -z "${DATABASE_DRIVER}" ] && DATABASE_DRIVER="mysqli"
if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then
echo "Invalid combination -d ${DBMS} -a ${DATABASE_DRIVER}" >&2
exit 1
fi
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="8.0"
if ! [[ ${DBMS_VERSION} =~ ^(8.0|8.4|9.0)$ ]]; then
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
exit 1
fi
;;
postgres)
if [ -n "${DATABASE_DRIVER}" ]; then
echo "Invalid combination -d ${DBMS} -a ${DATABASE_DRIVER}" >&2
exit 1
fi
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="16"
if ! [[ ${DBMS_VERSION} =~ ^(12|13|14|15|16|17)$ ]]; then
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
exit 1
fi
;;
sqlite)
if [ -n "${DATABASE_DRIVER}" ]; then
echo "Invalid combination -d ${DBMS} -a ${DATABASE_DRIVER}" >&2
exit 1
fi
;;
*)
echo "Invalid option -d ${DBMS}" >&2
exit 1
;;
esac
}
loadHelp() {
read -r -d '' HELP <<EOF
TYPO3 Extension test runner. Execute tests in Docker containers.
Usage: $0 [options] [file]
Options:
-s <...>
Specifies which test suite to run
- cgl: PHP CS Fixer check/fix
- clean: Clean temporary files
- composer: Run composer commands
- composerUpdate: Update dependencies
- e2e: Playwright E2E tests (requires running TYPO3)
- functional: PHP functional tests
- functionalParallel: Parallel functional tests (faster)
- functionalCoverage: Functional tests with coverage
- lint: PHP linting
- phpstan: PHPStan static analysis
- unit: PHP unit tests (default)
- unitCoverage: Unit tests with coverage
- fuzz: Fuzz tests
- mutation: Mutation testing
-d <sqlite|mariadb|mysql|postgres>
Database for functional tests (default: sqlite)
-i version
Database version (mariadb: 11.8, mysql: 8.0, postgres: 16)
-p <8.2|8.3|8.4|8.5>
PHP version (default: 8.5)
-x
Enable Xdebug for debugging
-n
Dry-run mode (for cgl, rector)
-h
Show this help
Examples:
# Run unit tests
./Build/Scripts/runTests.sh -s unit
# Run functional tests with MariaDB
./Build/Scripts/runTests.sh -s functional -d mariadb
# Run E2E tests (uses PHP built-in server + MySQL container)
./Build/Scripts/runTests.sh -s e2e
E2E Tests:
E2E tests use a PHP built-in server + MySQL container.
Usage: ./Build/Scripts/runTests.sh -s e2e
Custom URL: TYPO3_BASE_URL=http://localhost:8080 ./Build/Scripts/runTests.sh -s e2e
EOF
}
# Check container runtime
if ! type "docker" >/dev/null 2>&1 && ! type "podman" >/dev/null 2>&1; then
echo "This script requires docker or podman." >&2
exit 1
fi
# Option defaults
TEST_SUITE="unit"
DATABASE_DRIVER=""
DBMS="sqlite"
DBMS_VERSION=""
PHP_VERSION="8.5"
PHP_XDEBUG_ON=0
PHP_XDEBUG_PORT=9003
CGLCHECK_DRY_RUN=0
CI_PARAMS="${CI_PARAMS:-}"
CONTAINER_BIN=""
CONTAINER_HOST="host.docker.internal"
SUITE_EXIT_CODE=0
# Parse options
OPTIND=1
while getopts "a:b:d:i:s:p:xy:nhu" OPT; do
case ${OPT} in
a) DATABASE_DRIVER=${OPTARG} ;;
s) TEST_SUITE=${OPTARG} ;;
b) CONTAINER_BIN=${OPTARG} ;;
d) DBMS=${OPTARG} ;;
i) DBMS_VERSION=${OPTARG} ;;
p) PHP_VERSION=${OPTARG} ;;
x) PHP_XDEBUG_ON=1 ;;
y) PHP_XDEBUG_PORT=${OPTARG} ;;
n) CGLCHECK_DRY_RUN=1 ;;
h) loadHelp; echo "${HELP}"; exit 0 ;;
u) TEST_SUITE=update ;;
\?) exit 1 ;;
esac
done
handleDbmsOptions
# CUSTOMIZE: Set your extension version
COMPOSER_ROOT_VERSION="1.x-dev"
HOST_UID=$(id -u)
USERSET=""
if [ "$(uname)" != "Darwin" ]; then
USERSET="--user $HOST_UID"
fi
# Navigate to project root
THIS_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$THIS_SCRIPT_DIR" || exit 1
cd ../../ || exit 1
ROOT_DIR="${PWD}"
# Create cache directories
mkdir -p .Build/.cache
IMAGE_PREFIX="docker.io/"
TYPO3_IMAGE_PREFIX="ghcr.io/typo3/"
CONTAINER_INTERACTIVE="-it --init"
IS_CORE_CI=0
if [ "${CI}" == "true" ] || ! [ -t 0 ]; then
IS_CORE_CI=1
IMAGE_PREFIX=""
CONTAINER_INTERACTIVE=""
fi
# Determine container binary
if [[ -z "${CONTAINER_BIN}" ]]; then
if type "podman" >/dev/null 2>&1; then
CONTAINER_BIN="podman"
elif type "docker" >/dev/null 2>&1; then
CONTAINER_BIN="docker"
fi
fi
# Container images
IMAGE_PHP="${TYPO3_IMAGE_PREFIX}core-testing-$(echo "php${PHP_VERSION}" | sed -e 's/\.//'):latest"
IMAGE_ALPINE="${IMAGE_PREFIX}alpine:3.8"
IMAGE_MARIADB="docker.io/mariadb:${DBMS_VERSION}"
IMAGE_MYSQL="docker.io/mysql:${DBMS_VERSION}"
IMAGE_POSTGRES="docker.io/postgres:${DBMS_VERSION}-alpine"
IMAGE_PLAYWRIGHT="mcr.microsoft.com/playwright:v1.57.0-noble"
# Optional: Mock OAuth server for OAuth integration tests
# IMAGE_MOCK_OAUTH="ghcr.io/navikt/mock-oauth2-server:3.0.1"
shift $((OPTIND - 1))
# CUSTOMIZE: Replace 'my-extension' with your extension key
SUFFIX=${RANDOM}
NETWORK="my-extension-${SUFFIX}"
"${CONTAINER_BIN}" network create "${NETWORK}" >/dev/null
if [ "${CONTAINER_BIN}" = "docker" ]; then
CONTAINER_COMMON_PARAMS="${CONTAINER_INTERACTIVE} --rm --network ${NETWORK} --add-host "${CONTAINER_HOST}:host-gateway" ${USERSET} -v ${ROOT_DIR}:${ROOT_DIR} -w ${ROOT_DIR}"
else
CONTAINER_HOST="host.containers.internal"
CONTAINER_COMMON_PARAMS="${CONTAINER_INTERACTIVE} ${CI_PARAMS} --rm --network ${NETWORK} -v ${ROOT_DIR}:${ROOT_DIR} -w ${ROOT_DIR}"
fi
if [ "${PHP_XDEBUG_ON}" -eq 0 ]; then
XDEBUG_MODE="-e XDEBUG_MODE=off"
XDEBUG_CONFIG=" "
else
XDEBUG_MODE="-e XDEBUG_MODE=debug -e XDEBUG_TRIGGER=foo"
XDEBUG_CONFIG="client_port=${PHP_XDEBUG_PORT} client_host=${CONTAINER_HOST}"
fi
# PHP performance options
PHP_OPCACHE_OPTS=(-d opcache.enable_cli=1 -d opcache.jit=1255 -d opcache.jit_buffer_size=128M)
# Functional/e2e-backend suites run WITHOUT the JIT: the tracing JIT in the
# container PHP builds (reproduced on 8.3 and 8.5) can segfault silently
# during suite bootstrap for certain - perfectly valid - source shapes
# (t3x-nr-llm#351: adding a plain property+getter+setter to an entity
# flipped it). Identical runs with opcache.jit=off pass; functionalCoverage
# below already ran without the JIT. Functional tests are IO-bound, so the
# JIT buys nothing here anyway.
PHP_FUNCTIONAL_OPTS=(-d opcache.enable_cli=1)
# SQLite functional databases: the testing-framework writes them to
# <TYPO3_PATH_ROOT>/typo3temp/var/tests/functional-sqlite-dbs/, and
# typo3/cms-composer-installers sets TYPO3_PATH_ROOT to extra.typo3/cms.web-dir
# from composer.json. The tmpfs has to sit on exactly that directory, or the
# databases land on the bind mount instead. composer.json is parsed by PHP
# inside the test image, so the host needs no JSON tool.
#
# The PHP step resolves web-dir the way typo3/cms-composer-installers 5.0.1 and
# 5.0.2 do (src/Plugin/Config.php, line numbers of 5.0.2):
# 35 default "public"
# 71 extra.typo3/cms is used only when it is a non-empty array
# 213 root package typo3/cms: web-dir "."
# 91 trailing "/" and "\" are stripped; null becomes "", the composer root
# 170-179 "" is the composer root, "/..." or "X:..." is absolute,
# anything else is relative to the composer root
# 230-236 the result, normalised by Composer's Filesystem::normalizePath
# ("\" to "/", "." and ".." resolved), must start with the composer
# root, or web-dir is reset to "public" with a warning
# It prints web-dir relative to the composer root. The installer checks against
# a placeholder root, "/fake/root", so it also accepts values that point
# outside the extension: an absolute path below that placeholder, or a ".."
# path that climbs out and back in under a name starting with "root"
# ("../root", "../root/public", "../rootx"). Of the values the installer keeps,
# any absolute one and any relative one whose segments climb above the composer
# root at some point stop the run, and so do "{$...}" placeholders.
# PHP exits 3 for a composer.json it cannot use; any other failure is the
# container step itself.
#
# The sqlite branches create the directory on the host before the run and pass
# mode=1777. A tmpfs over an existing directory takes that directory's 0755 and
# is owned by root, so the container user cannot write to it without the mode.
# Without the mkdir, the daemon creates the missing mount point and its parents
# as root, and the container user can no longer create the test instances
# next to it in typo3temp/var/tests/.
if [[ ${TEST_SUITE} =~ ^functional(Parallel|Coverage)$ ]] || [[ ${TEST_SUITE} == "functional" && ${DBMS} == "sqlite" ]]; then
WEB_DIR_EXIT=0
# SC2016: the single-quoted $ are PHP variables. SC2086: CI_PARAMS holds
# several options and is split on purpose, as in every other run below.
# shellcheck disable=SC2016,SC2086
WEB_DIR=$("${CONTAINER_BIN}" run --rm -i ${CI_PARAMS} "${IMAGE_PHP}" php -r '
$c = json_decode(stream_get_contents(STDIN), true);
if (!is_array($c)) { fwrite(STDERR, "composer.json is not valid JSON\n"); exit(3); }
if (($c["name"] ?? "") === "typo3/cms") { echo "."; exit(0); }
$t = $c["extra"]["typo3/cms"] ?? [];
if (!is_array($t) || $t === [] || !array_key_exists("web-dir", $t)) { echo "public"; exit(0); }
$v = $t["web-dir"];
if ($v === null) {
$v = "";
} elseif (is_string($v) || is_int($v) || is_float($v)) {
$v = (string)$v;
} else {
fwrite(STDERR, "extra.typo3/cms.web-dir must be a string\n"); exit(3);
}
if (str_contains($v, "{" . chr(36))) { fwrite(STDERR, "placeholders in extra.typo3/cms.web-dir are not supported\n"); exit(3); }
$v = rtrim($v, "/\\");
$base = "/fake/root";
$isAbs = $v !== "" && ($v[0] === "/" || (isset($v[1]) && $v[1] === ":"));
$path = strtr($v === "" ? $base : ($isAbs ? $v : $base . "/" . $v), "\\", "/");
$parts = [];
foreach (explode("/", $path) as $p) {
if ($p === "..") { array_pop($parts); } elseif ($p !== "." && $p !== "") { $parts[] = $p; }
}
$n = (str_starts_with($path, "/") ? "/" : "") . implode("/", $parts);
if (!str_starts_with($n, $base)) {
fwrite(STDERR, "Warning: extra.typo3/cms.web-dir is not below the composer root; like typo3/cms-composer-installers, using public\n");
echo "public"; exit(0);
}
$depth = 0;
foreach (explode("/", strtr($v, "\\", "/")) as $p) {
if ($p === "..") { $depth--; } elseif ($p !== "." && $p !== "") { $depth++; }
if ($depth < 0) { break; }
}
if ($isAbs || $depth < 0) {
fwrite(STDERR, "extra.typo3/cms.web-dir points outside the extension, which runTests.sh does not support\n"); exit(3);
}
if ($n === $base) { echo "."; exit(0); }
if (!str_starts_with($n, $base . "/")) {
fwrite(STDERR, "extra.typo3/cms.web-dir points outside the extension, which runTests.sh does not support\n"); exit(3);
}
echo substr($n, strlen($base) + 1);
' < "${ROOT_DIR}/composer.json") || WEB_DIR_EXIT=$?
if [[ ${WEB_DIR_EXIT} -eq 3 ]]; then
echo "Cannot use extra.typo3/cms.web-dir from ${ROOT_DIR}/composer.json (reason above)" >&2
cleanUp
exit 1
elif [[ ${WEB_DIR_EXIT} -ne 0 || -z ${WEB_DIR} ]]; then
echo "The ${IMAGE_PHP} container that reads web-dir from composer.json failed (exit ${WEB_DIR_EXIT})" >&2
cleanUp
exit 1
fi
SQLITE_DB_DIR="${ROOT_DIR}/${WEB_DIR}/typo3temp/var/tests/functional-sqlite-dbs/"
fi
# Suite execution
case ${TEST_SUITE} in
cgl)
if [ "${CGLCHECK_DRY_RUN}" -eq 1 ]; then
SHELL_COMMAND="php ${PHP_OPCACHE_OPTS[*]} -dxdebug.mode=off .Build/bin/php-cs-fixer fix -v --dry-run --diff"
else
SHELL_COMMAND="php ${PHP_OPCACHE_OPTS[*]} -dxdebug.mode=off .Build/bin/php-cs-fixer fix -v"
fi
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "cgl-${SUFFIX}" -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" "${IMAGE_PHP}" /bin/sh -c "${SHELL_COMMAND}"
SUITE_EXIT_CODE=$?
;;
clean)
cleanCacheFiles
;;
composer)
COMMAND=(composer "$@")
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "composer-${SUFFIX}" -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
composerUpdate)
rm -rf .Build/bin/ .Build/vendor ./composer.lock
COMMAND=(composer install --no-ansi --no-interaction --no-progress)
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "composer-${SUFFIX}" -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
e2e)
# E2E tests use a PHP built-in server + MySQL container (not DDEV)
TYPO3_BASE_URL="${TYPO3_BASE_URL:-http://localhost:8080}"
echo "E2E tests using TYPO3_BASE_URL: ${TYPO3_BASE_URL}"
mkdir -p .Build/.cache/npm
mkdir -p node_modules
# Check for permission issues (root-owned files from previous container runs)
if [ -d "node_modules" ] && [ "$(find node_modules -maxdepth 1 -user root 2>/dev/null | head -1)" ]; then
echo "Error: node_modules contains root-owned files."
echo "Please remove and retry: sudo rm -rf node_modules"
exit 1
fi
SHELL_COMMAND="npm ci && npx playwright test $*"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "e2e-${SUFFIX}" \
-e TYPO3_BASE_URL="${TYPO3_BASE_URL}" \
-e CI="${CI:-}" \
-e npm_config_cache="${ROOT_DIR}/.Build/.cache/npm" \
"${IMAGE_PLAYWRIGHT}" /bin/bash -c "${SHELL_COMMAND}"
SUITE_EXIT_CODE=$?
;;
functional)
COMMAND=(php "${PHP_FUNCTIONAL_OPTS[@]}" -dxdebug.mode=off .Build/bin/phpunit -c Tests/Build/FunctionalTests.xml --exclude-group "not-${DBMS}" "$@")
case ${DBMS} in
mariadb)
echo "Using driver: ${DATABASE_DRIVER}"
"${CONTAINER_BIN}" run --rm ${CI_PARAMS} --name "mariadb-func-${SUFFIX}" --network "${NETWORK}" -d -e MYSQL_ROOT_PASSWORD=funcp --tmpfs /var/lib/mysql/:rw,noexec,nosuid "${IMAGE_MARIADB}" >/dev/null
waitFor "mariadb-func-${SUFFIX}" 3306
CONTAINERPARAMS="-e typo3DatabaseDriver=${DATABASE_DRIVER} -e typo3DatabaseName=func_test -e typo3DatabaseUsername=root -e typo3DatabaseHost=mariadb-func-${SUFFIX} -e typo3DatabasePassword=funcp"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
mysql)
echo "Using driver: ${DATABASE_DRIVER}"
"${CONTAINER_BIN}" run --rm ${CI_PARAMS} --name "mysql-func-${SUFFIX}" --network "${NETWORK}" -d -e MYSQL_ROOT_PASSWORD=funcp --tmpfs /var/lib/mysql/:rw,noexec,nosuid "${IMAGE_MYSQL}" >/dev/null
waitFor "mysql-func-${SUFFIX}" 3306
CONTAINERPARAMS="-e typo3DatabaseDriver=${DATABASE_DRIVER} -e typo3DatabaseName=func_test -e typo3DatabaseUsername=root -e typo3DatabaseHost=mysql-func-${SUFFIX} -e typo3DatabasePassword=funcp"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
postgres)
"${CONTAINER_BIN}" run --rm ${CI_PARAMS} --name "postgres-func-${SUFFIX}" --network "${NETWORK}" -d -e POSTGRES_PASSWORD=funcp -e POSTGRES_USER=funcu --tmpfs /var/lib/postgresql/data:rw,noexec,nosuid "${IMAGE_POSTGRES}" >/dev/null
waitFor "postgres-func-${SUFFIX}" 5432
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_pgsql -e typo3DatabaseName=bamboo -e typo3DatabaseUsername=funcu -e typo3DatabaseHost=postgres-func-${SUFFIX} -e typo3DatabasePassword=funcp"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
sqlite)
mkdir -p "${SQLITE_DB_DIR}"
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_sqlite"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} --tmpfs "${SQLITE_DB_DIR}:rw,noexec,nosuid,mode=1777" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
esac
;;
functionalParallel)
# Parallel functional tests using xargs
# Each test file runs in isolation with its own SQLite database
mkdir -p "${SQLITE_DB_DIR}"
# CI: fixed jobs for predictable resource usage
# Local: half of available CPUs
if [ "${CI}" == "true" ]; then
PARALLEL_JOBS=4
else
PARALLEL_JOBS="\$(((\$(nproc) + 1) / 2))"
fi
SHELL_COMMAND="find Tests/Functional -name '*Test.php' | xargs -P${PARALLEL_JOBS} -I{} php ${PHP_FUNCTIONAL_OPTS[*]} -dxdebug.mode=off .Build/bin/phpunit -c Tests/Build/FunctionalTests.xml {}"
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_sqlite"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-parallel-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} --tmpfs "${SQLITE_DB_DIR}:rw,noexec,nosuid,mode=1777" "${IMAGE_PHP}" /bin/sh -c "${SHELL_COMMAND}"
SUITE_EXIT_CODE=$?
;;
functionalCoverage)
mkdir -p .Build/coverage
COMMAND=(php -d opcache.enable_cli=1 .Build/bin/phpunit -c Tests/Build/FunctionalTests.xml --coverage-clover=.Build/coverage/functional.xml --coverage-html=.Build/coverage/html-functional --coverage-text "$@")
mkdir -p "${SQLITE_DB_DIR}"
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_sqlite"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "functional-coverage-${SUFFIX}" -e XDEBUG_MODE=coverage ${CONTAINERPARAMS} --tmpfs "${SQLITE_DB_DIR}:rw,noexec,nosuid,mode=1777" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
lint)
SHELL_COMMAND="find . -name \\*.php ! -path \"./.Build/\\*\" -print0 | xargs -0 -n1 -P\$(nproc) php ${PHP_OPCACHE_OPTS[*]} -dxdebug.mode=off -l >/dev/null"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "lint-${SUFFIX}" "${IMAGE_PHP}" /bin/sh -c "${SHELL_COMMAND}"
SUITE_EXIT_CODE=$?
;;
phpstan)
SHELL_COMMAND="php ${PHP_OPCACHE_OPTS[*]} -dxdebug.mode=off .Build/bin/phpstan analyse"
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "phpstan-${SUFFIX}" -e "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" "${IMAGE_PHP}" /bin/sh -c "${SHELL_COMMAND}"
SUITE_EXIT_CODE=$?
;;
unit)
COMMAND=(php "${PHP_OPCACHE_OPTS[@]}" -dxdebug.mode=off .Build/bin/phpunit -c Tests/Build/phpunit.xml --testsuite Unit "$@")
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "unit-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
unitCoverage)
mkdir -p .Build/coverage
COMMAND=(php -d opcache.enable_cli=1 .Build/bin/phpunit -c Tests/Build/phpunit.xml --testsuite Unit --coverage-clover=.Build/coverage/unit.xml --coverage-html=.Build/coverage/html-unit --coverage-text "$@")
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "unit-coverage-${SUFFIX}" -e XDEBUG_MODE=coverage "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
fuzz)
COMMAND=(php "${PHP_OPCACHE_OPTS[@]}" -dxdebug.mode=off .Build/bin/phpunit -c Tests/Build/phpunit.xml --testsuite Fuzz "$@")
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "fuzz-${SUFFIX}" ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
mutation)
COMMAND=(php -d opcache.enable_cli=1 .Build/bin/infection --configuration=infection.json5 --threads=4 "$@")
"${CONTAINER_BIN}" run ${CONTAINER_COMMON_PARAMS} --name "mutation-${SUFFIX}" -e XDEBUG_MODE=coverage "${IMAGE_PHP}" "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
;;
update)
echo "> Updating ${TYPO3_IMAGE_PREFIX}core-testing-* images..."
"${CONTAINER_BIN}" images "${TYPO3_IMAGE_PREFIX}core-testing-*" --format "{{.Repository}}:{{.Tag}}" | xargs -I {} "${CONTAINER_BIN}" pull {}
;;
*)
loadHelp
echo "Invalid -s option: ${TEST_SUITE}" >&2
echo "${HELP}" >&2
exit 1
;;
esac
cleanUp
# Print summary
echo "" >&2
echo "###########################################################################" >&2
echo "Result of ${TEST_SUITE}" >&2
echo "Container runtime: ${CONTAINER_BIN}" >&2
if [[ ${IS_CORE_CI} -eq 1 ]]; then
echo "Environment: CI" >&2
else
echo "Environment: local" >&2
fi
echo "PHP: ${PHP_VERSION}" >&2
if [[ ${TEST_SUITE} =~ ^functional ]]; then
echo "DBMS: ${DBMS}" >&2
fi
if [[ ${SUITE_EXIT_CODE} -eq 0 ]]; then
echo "SUCCESS" >&2
else
echo "FAILURE" >&2
fi
echo "###########################################################################" >&2
echo "" >&2
exit "${SUITE_EXIT_CODE}"
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |