Download the PHP package sbuerk/typo3-site-based-test-trait without Composer
On this page you can find all versions of the php package sbuerk/typo3-site-based-test-trait. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package typo3-site-based-test-trait
Provides modified TYPO3 SiteBasedTestTrait
Compatibility
branch | version | TYPO3 | testing-framework | PHP | CI State |
---|---|---|---|---|---|
main | 3.x.x-dev | main,14.0.0-dev | main, 9 | 8.2, 8.3, 8.4 | |
2 | 2.x.x-dev | 13.4,13.4.x-dev | 8,9 | 8.2, 8.3, 8.4 | |
1 | 1.x.x-dev | 12.4,12.4.x-dev | 8 | 8.1, 8.2, 8.3, 8.4 |
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 extending the typo3/testing-framework
counter-part is provided with a modified setUpFrontendRootPage() method
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
[!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.
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:
Differences to the TYPO3 Core implementation of SiteBasedTestTrait
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
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()
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
[!IMPORTANT] TYPO3 v13 introduced
array $dependency
as 4th argument, which is removed in this implementation in favour of the more generic customarray $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:
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.
Method signature:
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.
Extended FunctionalTestCase
A extended FunctionalTestCase
is provided with a modified setUpFrontendRootPage() method.
FunctionalTestCase::setUpFrontendRootPage()
Signature of modified method:
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:
of without named arguments:
Create a release (maintainer only)
Prerequisites:
- git binary
- ssh key allowed to push new branches to the repository
Checkout the release branch and
No need to create GitHub release manually - the publish workflow takes care of this.