Skip to content

netresearch/typo3-testing-skill / skills/typo3-testing

typo3-testing

Flagged

Use 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.

FileKindSize
SKILL.mdskill md6.8 KB
assets/.php-cs-fixer.dist.phpscript7.0 KB
assets/AGENTS.mdmarkdown5.0 KB
assets/Build/Scripts/runTests.shexecutablescript27.5 KB
assets/Build/playwright/.nvmrcother6 B
assets/Build/playwright/package.jsonmanifest535 B
assets/Build/playwright/playwright.config.tsscript1.3 KB
assets/Build/playwright/tests/playwright/accessibility/modules.spec.tsscript2.0 KB
assets/Build/playwright/tests/playwright/config.tsscript712 B
assets/Build/playwright/tests/playwright/e2e/backend-module.spec.tsscript1.9 KB
assets/Build/playwright/tests/playwright/fixtures/setup-fixtures.tsscript2.7 KB
assets/Build/playwright/tests/playwright/helper/login.setup.tsscript975 B
assets/FunctionalTests.xmlconfig1.4 KB
assets/FunctionalTestsBootstrap.phpscript1.6 KB
assets/Makefileother2.3 KB
assets/UnitTests.xmlconfig890 B
assets/UnitTestsBootstrap.phpscript2.1 KB
assets/bootstrap.phpscript1.4 KB
assets/codecov.ymlconfig1.6 KB
assets/docker/codeception.ymlconfig979 B
assets/docker/docker-compose.ymlconfig1.4 KB
assets/example-tests/ExampleAcceptanceCest.phpscript2.2 KB
assets/example-tests/ExampleFunctionalTest.phpscript2.4 KB
assets/example-tests/ExampleUnitTest.phpscript1.6 KB
assets/fixtures/README.mdmarkdown2.0 KB
assets/fixtures/be_users.csvother361 B
assets/fixtures/pages.csvother257 B
assets/fixtures/sys_category.csvother228 B
assets/fixtures/tt_content.csvother338 B
assets/github-actions-e2e.ymlconfig8.8 KB
assets/github-actions-tests.ymlconfig6.3 KB
assets/infection.json5other2.8 KB
assets/phpat.neonother330 B
assets/phpat.phpscript8.4 KB
assets/phpstan-baseline.neonother365 B
assets/phpstan.neonother1.4 KB
assets/rector.phpscript2.9 KB
checkpoints.yamlconfig61.7 KB
references/accessibility-testing.mdmarkdown7.6 KB
references/architecture-testing.mdmarkdown4.4 KB
references/asset-templates-guide.mdmarkdown3.4 KB
references/backend-module-render-verification.mdmarkdown9.7 KB
references/backend-user-access-testing.mdmarkdown9.5 KB
references/captainhook-setup.mdmarkdown2.4 KB
references/ci-cd.mdmarkdown39.5 KB
references/ci-debugging.mdmarkdown20.0 KB
references/ci-workflows-meta-package.mdmarkdown11.6 KB
references/crash-and-concurrency-testing.mdmarkdown4.8 KB
references/crypto-testing.mdmarkdown16.6 KB
references/datahandler-silent-rewrites.mdmarkdown7.2 KB
references/ddev-testing.mdmarkdown1.3 KB
references/e2e-testing.mdmarkdown53.0 KB
references/enforcement-rules.mdmarkdown5.7 KB
references/event-dispatch-testing.mdmarkdown2.8 KB
references/framework-compat-gate.mdmarkdown4.9 KB
references/functional-test-patterns.mdmarkdown11.0 KB
references/functional-testing.mdmarkdown46.3 KB
references/fuzz-testing.mdmarkdown8.6 KB
references/integration-testing.mdmarkdown14.1 KB
references/javascript-testing.mdmarkdown29.3 KB
references/live-instance-verification.mdmarkdown8.6 KB
references/mock-validity.mdmarkdown15.7 KB
references/mutation-testing.mdmarkdown36.0 KB
references/performance-testing.mdmarkdown11.2 KB
references/quality-tools.mdmarkdown25.5 KB
references/release-workflow-validation.mdmarkdown3.6 KB
references/sonarcloud.mdmarkdown18.8 KB
references/synthetic-secret-fixtures.mdmarkdown3.8 KB
references/tdd-discipline.mdmarkdown9.1 KB
references/test-environment-guards.mdmarkdown18.5 KB
references/test-runners.mdmarkdown24.6 KB
references/typo3-ci-config-patterns.mdmarkdown9.0 KB
references/typo3-v14-final-classes.mdmarkdown16.5 KB
references/unit-testing.mdmarkdown59.1 KB
scripts/generate-test.shexecutablescript6.0 KB
scripts/setup-testing.shexecutablescript6.3 KB
scripts/validate-setup.shexecutablescript4.0 KB

scripts/setup-testing.sh

View on GitHub
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH

#
# Setup TYPO3 testing infrastructure
#
# This script initializes testing infrastructure for TYPO3 extensions:
# - Composer dependencies
# - PHPUnit configurations
# - Directory structure
# - Optional: Docker Compose for acceptance tests
#

set -e

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Script configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
PROJECT_DIR="$(pwd)"

WITH_ACCEPTANCE=false

# Parse arguments
while getopts ":a" opt; do
    case ${opt} in
        a)
            WITH_ACCEPTANCE=true
            ;;
        \?)
            echo "Usage: $0 [-a]"
            echo "  -a    Include acceptance testing setup (Docker Compose, Codeception)"
            exit 1
            ;;
    esac
done

echo -e "${GREEN}=== TYPO3 Testing Infrastructure Setup ===${NC}"
echo

# Check if composer.json exists
if [ ! -f "${PROJECT_DIR}/composer.json" ]; then
    echo -e "${RED}Error: composer.json not found in current directory${NC}"
    echo "Please run this script from your TYPO3 extension root directory"
    exit 1
fi

# 1. Install testing framework dependencies
echo -e "${YELLOW}[1/6] Installing testing framework dependencies...${NC}"
# typo3/testing-framework 8.2 covers TYPO3 12.4 and 13.4 with PHPUnit 10 or 11;
# 9.x covers TYPO3 13.4 and 14.3 with PHPUnit 11.2.5+, 12.1.2+ (9.2) and
# 13.0.2+ (9.4). PHPUnit 10.5 stays allowed for TYPO3 12.4 on PHP 8.1: every
# later PHPUnit line needs PHP 8.2 or newer.
if ! grep -q "typo3/testing-framework" "${PROJECT_DIR}/composer.json"; then
    composer require --dev "typo3/testing-framework:^8.2 || ^9.0" --no-update
    echo -e "${GREEN}✓ Added typo3/testing-framework${NC}"
else
    echo -e "${GREEN}✓ typo3/testing-framework already present${NC}"
fi

# Install PHPUnit if not present
if ! grep -q "phpunit/phpunit" "${PROJECT_DIR}/composer.json"; then
    composer require --dev "phpunit/phpunit:^10.5 || ^11.2.5 || ^12.1.2 || ^13.0.2" --no-update
    echo -e "${GREEN}✓ Added phpunit/phpunit${NC}"
fi

composer update --no-progress

# 2. Create directory structure
echo -e "${YELLOW}[2/6] Creating directory structure...${NC}"
mkdir -p "${PROJECT_DIR}/Tests/Unit"
mkdir -p "${PROJECT_DIR}/Tests/Functional/Fixtures"
mkdir -p "${PROJECT_DIR}/Build/phpunit"
mkdir -p "${PROJECT_DIR}/Build/Scripts"
echo -e "${GREEN}✓ Directories created${NC}"

# 3. Copy PHPUnit configurations
echo -e "${YELLOW}[3/6] Installing PHPUnit configurations...${NC}"
if [ ! -f "${PROJECT_DIR}/Build/phpunit/UnitTests.xml" ]; then
    cp "${SKILL_DIR}/assets/UnitTests.xml" "${PROJECT_DIR}/Build/phpunit/"
    echo -e "${GREEN}✓ Created UnitTests.xml${NC}"
else
    echo -e "${YELLOW}⚠ UnitTests.xml already exists (skipped)${NC}"
fi

if [ ! -f "${PROJECT_DIR}/Build/phpunit/FunctionalTests.xml" ]; then
    cp "${SKILL_DIR}/assets/FunctionalTests.xml" "${PROJECT_DIR}/Build/phpunit/"
    echo -e "${GREEN}✓ Created FunctionalTests.xml${NC}"
else
    echo -e "${YELLOW}⚠ FunctionalTests.xml already exists (skipped)${NC}"
fi

if [ ! -f "${PROJECT_DIR}/Build/phpunit/FunctionalTestsBootstrap.php" ]; then
    cp "${SKILL_DIR}/assets/FunctionalTestsBootstrap.php" "${PROJECT_DIR}/Build/phpunit/"
    echo -e "${GREEN}✓ Created FunctionalTestsBootstrap.php${NC}"
else
    echo -e "${YELLOW}⚠ FunctionalTestsBootstrap.php already exists (skipped)${NC}"
fi

# 4. Create AGENTS.md templates
echo -e "${YELLOW}[4/6] Creating AGENTS.md templates...${NC}"
for dir in "${PROJECT_DIR}/Tests/Unit" "${PROJECT_DIR}/Tests/Functional"; do
    if [ ! -f "${dir}/AGENTS.md" ]; then
        cp "${SKILL_DIR}/assets/AGENTS.md" "${dir}/"
        echo -e "${GREEN}✓ Created ${dir}/AGENTS.md${NC}"
    else
        echo -e "${YELLOW}⚠ ${dir}/AGENTS.md already exists (skipped)${NC}"
    fi
done

# 5. Setup composer scripts
echo -e "${YELLOW}[5/6] Adding composer test scripts...${NC}"
if ! grep -q "ci:test:php:unit" "${PROJECT_DIR}/composer.json"; then
    echo -e "${GREEN}ℹ Add these scripts to your composer.json:${NC}"
    cat << 'EOF'

"scripts": {
    "ci:test": [
        "@ci:test:php:lint",
        "@ci:test:php:phpstan",
        "@ci:test:php:unit",
        "@ci:test:php:functional"
    ],
    "ci:test:php:lint": "phplint",
    "ci:test:php:phpstan": "phpstan analyze --configuration Build/phpstan.neon --no-progress",
    "ci:test:php:unit": "phpunit -c Build/phpunit/UnitTests.xml",
    "ci:test:php:functional": "phpunit -c Build/phpunit/FunctionalTests.xml"
}
EOF
else
    echo -e "${GREEN}✓ Test scripts already configured${NC}"
fi

# 6. Setup acceptance testing if requested
if [ "${WITH_ACCEPTANCE}" = true ]; then
    echo -e "${YELLOW}[6/6] Setting up acceptance testing...${NC}"

    # Install Codeception
    if ! grep -q "codeception/codeception" "${PROJECT_DIR}/composer.json"; then
        composer require --dev codeception/codeception codeception/module-webdriver --no-update
        composer update --no-progress
        echo -e "${GREEN}✓ Installed Codeception${NC}"
    fi

    # Create acceptance test directory
    mkdir -p "${PROJECT_DIR}/Tests/Acceptance"

    # Copy Docker Compose and Codeception config
    if [ ! -f "${PROJECT_DIR}/Build/docker-compose.yml" ]; then
        cp "${SKILL_DIR}/assets/docker/docker-compose.yml" "${PROJECT_DIR}/Build/"
        echo -e "${GREEN}✓ Created docker-compose.yml${NC}"
    fi

    if [ ! -f "${PROJECT_DIR}/codeception.yml" ]; then
        cp "${SKILL_DIR}/assets/docker/codeception.yml" "${PROJECT_DIR}/"
        echo -e "${GREEN}✓ Created codeception.yml${NC}"
    fi

    # Initialize Codeception
    if [ ! -d "${PROJECT_DIR}/Tests/Acceptance/_support" ]; then
        vendor/bin/codecept bootstrap
        echo -e "${GREEN}✓ Initialized Codeception${NC}"
    fi
else
    echo -e "${YELLOW}[6/6] Skipping acceptance testing setup (use -a flag to include)${NC}"
fi

echo
echo -e "${GREEN}=== Setup Complete ===${NC}"
echo
echo "Next steps:"
echo "1. Generate your first test:"
echo "   ${SKILL_DIR}/scripts/generate-test.sh unit MyClass"
echo
echo "2. Run tests:"
echo "   composer ci:test:php:unit"
echo "   composer ci:test:php:functional"
echo
echo "3. Add CI/CD workflow (optional):"
echo "   cp ${SKILL_DIR}/assets/github-actions-tests.yml .github/workflows/tests.yml"
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall