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

assets/phpat.php

View on GitHub
<?php

declare(strict_types=1);

/*
 * PHPat Architecture Test Rules Template
 *
 * This file defines architecture rules enforced via PHPStan.
 * Run with: Build/Scripts/runTests.sh -s phpstan
 *
 * CUSTOMIZATION REQUIRED:
 * - Replace 'Vendor\ExtensionName' with your actual namespace
 * - Adjust layer rules based on your extension's architecture
 * - Add/remove rules based on your security requirements
 */

namespace Vendor\ExtensionName\Tests\Architecture;

use PHPat\Selector\Selector;
use PHPat\Test\Builder\BuildStep;
use PHPat\Test\PHPat;

/**
 * Architecture tests for TYPO3 extension.
 *
 * Enforces clean architecture boundaries and security patterns.
 *
 * Layer dependency rules (allowed dependencies flow downward):
 *
 *   Controller/Command (presentation)
 *          ↓
 *      Service (application)
 *          ↓
 *   Domain/Repository (core)
 *          ↓
 *   Exception/Event (shared kernel)
 */
final class ArchitectureTest
{
    // =========================================================================
    // IMMUTABILITY RULES - Security-critical classes must be immutable
    // =========================================================================

    /**
     * Events must be readonly for immutability.
     *
     * PSR-14 events should never be modified after creation.
     */
    public function testEventsMustBeReadonly(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Event'))
            ->shouldBeReadonly()
            ->because('events must be immutable for security and predictability');
    }

    /**
     * DTOs must be readonly.
     *
     * Data Transfer Objects should be immutable value objects.
     */
    public function testDtosMustBeReadonly(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Domain\Dto'))
            ->shouldBeReadonly()
            ->because('DTOs must be immutable value objects');
    }

    // =========================================================================
    // FINALITY RULES - Security classes must not be extended
    // =========================================================================

    /**
     * Exceptions must be final.
     *
     * Prevents exception hierarchy manipulation attacks.
     */
    public function testExceptionsMustBeFinal(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Exception'))
            ->shouldBeFinal()
            ->because('exceptions should not be extended for security');
    }

    // =========================================================================
    // INTERFACE RULES - Ensure proper abstractions
    // =========================================================================

    /**
     * Services must implement an interface.
     *
     * Enables dependency injection and testing.
     */
    public function testServicesMustImplementInterface(): BuildStep
    {
        return PHPat::rule()
            ->classes(
                Selector::classname('/^Vendor\\\\ExtensionName\\\\Service\\\\.*Service$/', true),
            )
            ->excluding(
                Selector::classname('/.*Interface$/', true),
                Selector::classname('/.*Factory$/', true),
            )
            ->shouldImplement()
            ->classes(Selector::classname('/.*Interface$/', true))
            ->because('services should be injected via interfaces for testability');
    }

    // =========================================================================
    // LAYER DEPENDENCY RULES - Enforce clean architecture
    // =========================================================================

    /**
     * Services must not depend on Controllers.
     *
     * Services are application layer, controllers are presentation.
     */
    public function testServicesDoNotDependOnControllers(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Service'))
            ->shouldNotDependOn()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Controller'))
            ->because('services should be independent of the presentation layer');
    }

    /**
     * Services must not depend on Commands.
     *
     * CLI commands are presentation layer.
     */
    public function testServicesDoNotDependOnCommands(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Service'))
            ->shouldNotDependOn()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Command'))
            ->because('services should be independent of CLI commands');
    }

    /**
     * Domain layer must not depend on infrastructure.
     *
     * Domain models should be pure and framework-independent.
     */
    public function testDomainDoesNotDependOnInfrastructure(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Domain'))
            ->shouldNotDependOn()
            ->classes(
                Selector::inNamespace('Vendor\ExtensionName\Controller'),
                Selector::inNamespace('Vendor\ExtensionName\Command'),
                Selector::inNamespace('Vendor\ExtensionName\Hook'),
                Selector::inNamespace('Vendor\ExtensionName\Form'),
                Selector::inNamespace('Vendor\ExtensionName\Task'),
            )
            ->because('domain layer must be isolated from infrastructure concerns');
    }

    /**
     * Hooks must not depend on Controllers.
     *
     * TYPO3 hooks should call services, not controllers.
     */
    public function testHooksDoNotDependOnControllers(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Hook'))
            ->shouldNotDependOn()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Controller'))
            ->because('hooks should use services, not controllers');
    }

    /**
     * Commands must not depend on Controllers.
     *
     * CLI and web are separate presentation channels.
     */
    public function testCommandsDoNotDependOnControllers(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Command'))
            ->shouldNotDependOn()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Controller'))
            ->because('CLI commands should not use web controllers');
    }

    /**
     * Configuration must not depend on Services.
     *
     * Configuration is low-level infrastructure.
     */
    public function testConfigurationDoesNotDependOnServices(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Configuration'))
            ->shouldNotDependOn()
            ->classes(
                Selector::inNamespace('Vendor\ExtensionName\Service'),
                Selector::inNamespace('Vendor\ExtensionName\Controller'),
                Selector::inNamespace('Vendor\ExtensionName\Command'),
            )
            ->because('configuration should be low-level infrastructure');
    }

    /**
     * EventListeners must not depend on Controllers or Commands.
     *
     * Event handlers should only use services.
     */
    public function testEventListenersDoNotDependOnPresentation(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\EventListener'))
            ->shouldNotDependOn()
            ->classes(
                Selector::inNamespace('Vendor\ExtensionName\Controller'),
                Selector::inNamespace('Vendor\ExtensionName\Command'),
            )
            ->because('event listeners should use services, not presentation layer');
    }

    /**
     * Utilities must not depend on Services.
     *
     * Utilities should be stateless helper functions.
     */
    public function testUtilitiesDoNotDependOnServices(): BuildStep
    {
        return PHPat::rule()
            ->classes(Selector::inNamespace('Vendor\ExtensionName\Utility'))
            ->shouldNotDependOn()
            ->classes(
                Selector::inNamespace('Vendor\ExtensionName\Controller'),
                Selector::inNamespace('Vendor\ExtensionName\Command'),
                Selector::inNamespace('Vendor\ExtensionName\Hook'),
            )
            ->because('utilities should be stateless helpers');
    }
}
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