PHPCSStandards / PHP_CodeSniffer

PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.
BSD 3-Clause "New" or "Revised" License
880 stars 54 forks source link

Tests: stability tweaks for the non-sniff tests #576

Closed jrfnl closed 1 month ago

jrfnl commented 1 month ago

Description

AbstractMethodUnitTest: add "tear down" method to reset static properties

... to prevent changes to the values of these for one test, influencing another test.

This is only a stability tweak, there are no existing tests affected by this issue at this time.

Tests/ConfigDouble: bug fix - always reset Config statics after use

The Config class uses a number of static properties, which may be updated during tests. These were previously - prior to #275 - reset to their default values in the AbstractMethodUnitTest::resetTestFile() method, but this reset was inadvertently removed with the reasoning that, if all tests use the ConfigDouble, the reset would no longer be needed as the ConfigDouble resets on being initialized.

The flaw in this logic is that not all tests are guaranteed to use the ConfigDouble, which means that without the reset, the Config class may be left "dirty" after tests using the ConfigDouble, which could break tests.

This commit fixes this issue by:

This is only a stability tweak, there are no existing tests affected by this issue at this time.

Suggested changelog entry

N/A