Issue Task Resolved

#110708Unit tests leak global state into following tests

Stefan Bürk 09/15/26, 08:56 updated 09/15/26, 13:20

Description

Since the global state backup of unit tests is limited to test classes which opt in with the BackupGlobals attribute (#110624), a few unit tests leave global state behind, which breaks other tests in randomized unit test runs.

Tests leaking a request

ImageScriptServiceTest, IndexerTest, FileContentParserTest and YouTubeRendererTest set TYPO3_REQUEST in the globals and never unset it. The global state backup can not restore such request objects, so opting in to the backup does not help: YouTubeRendererTest opts in and still leaks its mocked request.

A following test reading the request fails, for example QueryFactoryTest::createDoesNotRespectStoragePageIfStaticOrRootLevelIsTrue and CorePasswordValidatorTest::validatorReturnsExpectedResults, with: No valid attribute applicationType found in request object.

Tests leaking configuration

RedisSessionBackendTest sets TYPO3_CONF_VARS SYS encryptionKey and PasswordGeneratorTest sets TYPO3_CONF_VARS SYS passwordPolicies, both without opting in to the global state backup. Both are reported by a unit test run with the options globals-backup and strict-global-state.

Steps to reproduce

bc. Build/Scripts/runTests.sh -s unit — —filter ‘QueryFactoryTest|ImageScriptServiceTest’ —order-by=random —random-order-seed=3

The same happens with IndexerTest instead of ImageScriptServiceTest, and in full randomized unit test runs, for example with the random seed 1789461382.

Solution

The tests leaking a request unset it on tear down, the tests leaking configuration opt in to the global state backup.

Reviews 2

History 14

  1. Stefan Bürk commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-09-15T13:20:09+00:00" > 09/15/26, 13:20 </span>

    Applied in changeset commit:45ff8a26d5a2ed5161b7a7ed93e4cdc9d99d40ce.