sabbelasichon / typo3-rector-testing-framework

Rector Rules for TYPO3 Testing Framework
MIT License
3 stars 1 forks source link

Rector Rule: Use $resetSingletonInstances property instead of teardown #2

Open tomasnorre opened 3 months ago

tomasnorre commented 3 months ago

As talked about in https://github.com/sabbelasichon/typo3-rector/issues/4275

It would be great to have a rule that used the

protected bool $resetSingletonInstances = true;

property set directly instead of using it in the teardown method

protected function tearDown(): void
{
    $this->resetSingletonInstances = true;
}

I'll be happy to give it a spin.

sbuerk commented 2 months ago

Note: $resetSingletonInstances = true is a lazy option. If you are in need to use that, your test setup adds more singleton instances to the GeneralUtility than it is consumend. Thus literally bootstrapping more than needed, and consuming expectation not matched.

The default resetSingletonInstances = false is the integration check telling you if your setup creates more instances then consumed (and expected).

Recently saw changes in the core adding more of these properties set to true, which we need to clean anyway (and deprecate / transform that check in TF to integrty check only).