PHPackages                             sbuerk/typo3-site-based-test-trait - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. sbuerk/typo3-site-based-test-trait

ActiveLibrary[Testing &amp; Quality](/categories/testing)

sbuerk/typo3-site-based-test-trait
==================================

Provides modified TYPO3 SiteBasedTestTrait and TF FunctionalTestCase.

3.0.0(1y ago)213.3k↑25.5%5GPL-2.0-or-laterPHPPHP ^8.2 || ^8.3 || ^8.4CI passing

Since Apr 13Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/sbuerk/typo3-site-based-test-trait)[ Packagist](https://packagist.org/packages/sbuerk/typo3-site-based-test-trait)[ RSS](/packages/sbuerk-typo3-site-based-test-trait/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (38)Versions (9)Used By (5)

Provides modified TYPO3 `SiteBasedTestTrait`
============================================

[](#provides-modified-typo3-sitebasedtesttrait)

Compatibility
-------------

[](#compatibility)

branchversionTYPO3testing-frameworkPHPCI Statemain3.x.x-devmain,14.0.0-devmain, 98.2, 8.3, 8.4[![CI](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml/badge.svg)](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml)22.x.x-dev13.4,13.4.x-dev8,98.2, 8.3, 8.4[![CI](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml/badge.svg?branch=2)](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml)11.x.x-dev12.4,12.4.x-dev88.1, 8.2, 8.3, 8.4[![CI](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml/badge.svg?branch=1)](https://github.com/sbuerk/typo3-site-based-test-trait/actions/workflows/ci.yml)Description
-----------

[](#description)

This package aims to provide a slightly extended (modified) `SiteBasedTestTrait` to allow easier usage for functional test TYPO3 Extensions or projects, hiding away internal requirements and cross TYPO3 Core Version changes introduced over time.

TYPO3 Core provides the trait only in the test namespace, stripped from distribution composer packages and are not available out of the box. It is possible to tell composer to install the package from source and requiring to add the TYPO3 system extension test namespace to the own root composer.json, which can easily be missed. This package makes the life easier.

Additionally, a custom [FunctionalTestCase](#extended-functionaltestcase) extending the `typo3/testing-framework`counter-part is provided with a modified [setUpFrontendRootPage() method](#functionaltestcasesetupfrontendrootpage)in preparation for TYPO3 v13 to make it possible to init site roots without creating a `sys_template` to make it possible to write site sets based templates. This is already provided for the TYPO3 v12 variante to have the same API in place to ensure working state without static code analysis errors when multiple core version tests are used, like it is the case for extensions.

Important

This should still be taken as experimental. It is tried hard to provide the same outer surface across versions as long as possible, but this cannot be guaranteed.

Installation
------------

[](#installation)

Note

This package should only be installed as development dependency and not deployed to production instances. It does not serve any purpose in production code.

```
composer require --dev 'sbuerk/typo3-site-based-test-trait'
```

Extension authors may support multiple TYPO3 versions with one extension version and needs to have working `SiteBasedTestTrait` for the corresponding TYPO3 version, which changes under the hood. To make maintenance and static code analysises easier, this package supports only one core version per version and extension authors needs to add conditional constraints for this package and let composer install the suitable version along with other dependencies, for example to suppor TYPO3 v12 and v13:

```
composer require --dev 'sbuerk/typo3-site-based-test-trait':'^1 || ^2'
```

Differences to the TYPO3 Core implementation of `SiteBasedTestTrait`
--------------------------------------------------------------------

[](#differences-to-the-typo3-core-implementation-of-sitebasedtesttrait)

### Fail test instead of mark it as skipped

[](#fail-test-instead-of-mark-it-as-skipped)

In case that something went wrong, language could not found in the preset and similar the TYPO3 implementation marks the test as skipped and literally hiding away issues which are hard to identify and find.

This package changes them and let tests fail when these things happen to point directly to an issue in the tests.

### Better code annotation

[](#better-code-annotation)

The annotations of the core are simple, related to the lower PHPStan level used. That produces a lot of noise in projects or extensions using PHPStan on a higher level and requires to add them to the baseline for each `FunctionalTestCase`.

To mitigate this, the annotations are enhanced for the cloned trait to survive higher PHPStan levels directly checked as part of the package testing.

### `writeSiteConfiguration()`

[](#writesiteconfiguration)

The `SiteBasedTestTrait::writeSiteConfiguration()` method got a additional argument `array $additional`, which can be used to provide additional `SiteConfig` content, for example routing information.

**Example Usage**

```
$this->writeSiteConfiguration(
    identifier: 'acme',
    site: [], // $this->buildSiteConfiguration(...)
    languages: [], // [$this->buildDefaultLanguageConfiguration(...), $this->buildLanguageConfiguration(...), ...]
    errorHandling: [], // $this->buildErrorHandlingConfiguration(...)
    // additional content
    additional: [
      'settings' => [
        'some_settings' => 123,
      ],
    ],
);
```

Important

TYPO3 v13 introduced `array $dependency` as 4th argument, which is removed in this implementation in favour of the more generic custom `array $additional` to keep same signature across package versions.

To add `SiteSets` dependency add it as part of the `$additional` array instead of the not adopted `array $dependencies` in TYPO3 v13:

```
$this->writeSiteConfiguration(
    identifier: 'acme',
    site: [], // $this->buildSiteConfiguration(...)
    languages: [], // [$this->buildDefaultLanguageConfiguration(...), $this->buildLanguageConfiguration(...), ...]
    errorHandling: [], // $this->buildErrorHandlingConfiguration(...)
    // additional content
    additional: [
      'dependencies' => [
        'my-vendor/site-set-identifier',
      ],
    ],
);
```

### `buildSiteConfiguration()`

[](#buildsiteconfiguration)

This method got a additional argument `$additionalRootConfiguration`, which also allows to add custom things on root level to the `SiteConfiguation` similar to [writeSiteConfiguration() argument additional](#writesiteconfiguration).

```
$this->buildSiteConfiguration(
    rootPageId: 1,
    base: 'https://acme.com/',
    websiteTitle: 'Home',
    additionalRootConfiguration: [
      'settings' => [
        'some_settings' => 123,
      ],
    ],
);
```

Method signature:

```
/**
 * @param non-empty-string $base
 * @param non-empty-string $websiteTitle
 * @param array $additionalRootConfiguration
 * @return array
 */
protected function buildSiteConfiguration(
    int $rootPageId,
    string $base = '/',
    string $websiteTitle = 'Home',
    array $additionalRootConfiguration = [],
): array {}
```

### `LANGUAGE_PRESETS` class property

[](#language_presets-class-property)

TYPO3 has a strong limitation which is read from the `LANGUAGE_PRESETS` class property, which is extended to allow custom values for language definitions in the `SiteConfiguration`, which `web-vision/deepltranslate-core` uses as an example.

```
protected const LANGUAGE_PRESETS = [
    'EN' => [
        'id' => 0,
        'title' => 'English',
        'locale' => 'en_US.UTF8',
        // custom values added to the language block
        'custom' => [
            'deepltranslate_language' => 'EN',
        ],
    ],
    'FR' => [
        'id' => 1,
        'title' => 'French',
        'locale' => 'fr_FR.UTF8',
        // custom values added to the language block
        'custom' => [
            'deepltranslate_language' => 'FR',
        ],
    ],
];
```

Extended `FunctionalTestCase`
-----------------------------

[](#extended--functionaltestcase)

A extended `FunctionalTestCase` is provided with a modified [setUpFrontendRootPage() method](#functionaltestcasesetupfrontendrootpage).

### `FunctionalTestCase::setUpFrontendRootPage()`

[](#functionaltestcasesetupfrontendrootpage)

Signature of modified method:

```
/**
 * Sets up a root-page containing TypoScript settings for frontend testing.
 *
 * Parameter `$typoScriptFiles` can either be
 * + `[
 *      'EXT:extension/path/first.typoscript',
 *      'EXT:extension/path/second.typoscript'
 *    ]`
 *   which just loads files to the setup setion of the TypoScript template
 *   record (legacy behavior of this method)
 * + `[
 *      'constants' => ['EXT:extension/path/constants.typoscript'],
 *      'setup' => ['EXT:extension/path/setup.typoscript']
 *    ]`
 *   which allows to define contents for the `constants` and `setup` part
 *   of the TypoScript template record at the same time
 *
 * @param int $pageId
 * @param array{constants?: string[], setup?: string[]}|string[] $typoScriptFiles
 * @param array $templateValues
 * @param bool $createSysTemplateRecord TRUE if sys_template record should be created, FALSE does not create one
 *                                      but removes an existing one.
 */
protected function setUpFrontendRootPage(
    int $pageId,
    array $typoScriptFiles = [],
    array $templateValues = [],
    bool $createSysTemplateRecord = true,
): void;
```

The main differnce is the 4th parameter. If this is set to false, no `sys_template` record is created for the given `$pageId` - and silently ignoring `$typoScriptFiles` and `$templateValues`.

To simply ensure page is set as rootpage without creating a `sys_template` row, following is enough:

```
$this->setUpFrontendRootPage(
    pageId: 1000,
    createSysTemplateRecord: false,
);
```

of without named arguments:

```
$this->setUpFrontendRootPage(
    1000,
    [], // will be ignored/not used due to false as 4th argument
    [], // will be ignored/not used due to false as 4th argument
    false,
);
```

Create a release (maintainer only)
----------------------------------

[](#create-a-release-maintainer-only)

Prerequisites:

- git binary
- ssh key allowed to push new branches to the repository

Checkout the release branch and

```
TAG_BRANCH="main" \
&& TAG_VERSION="1.2.3" \
&& git fetch --all \
&& git checkout ${TAG_BRANCH} \
&& git pull --rebase \
&& git tag "${TAG_VERSION}" \
&& git push --tags
```

No need to create GitHub release manually - the publish workflow takes care of this.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance69

Regular maintenance activity

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

400d ago

Major Versions

1.0.1 → 2.0.02025-04-13

1.0.2 → 2.0.12025-04-14

2.0.1 → 3.0.02025-04-14

PHP version history (2 changes)1.0.0PHP ^8.1 || ^8.2 || ^8.3 || ^8.4

2.0.0PHP ^8.2 || ^8.3 || ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/22ea8c0796de498c0d81554f12539e71bdb9b9359df3a82a7fb450867a68a680?d=identicon)[sbuerk](/maintainers/sbuerk)

---

Top Contributors

[![sbuerk](https://avatars.githubusercontent.com/u/1453466?v=4)](https://github.com/sbuerk "sbuerk (15 commits)")

---

Tags

testingtypo3

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sbuerk-typo3-site-based-test-trait/health.svg)

```
[![Health](https://phpackages.com/badges/sbuerk-typo3-site-based-test-trait/health.svg)](https://phpackages.com/packages/sbuerk-typo3-site-based-test-trait)
```

###  Alternatives

[phpunit/phpunit

The PHP Unit Testing framework.

20.0k910.7M134.8k](/packages/phpunit-phpunit)[phpunit/php-code-coverage

Library that provides collection, processing, and rendering functionality for PHP code coverage information.

8.9k892.4M1.5k](/packages/phpunit-php-code-coverage)[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/phpunit-bridge

Provides utilities for PHPUnit, especially user deprecation notices management

2.5k201.2M4.2k](/packages/symfony-phpunit-bridge)[behat/mink

Browser controller/emulator abstraction for PHP

1.6k86.1M606](/packages/behat-mink)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
