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:
Adding a __destruct() method to the ConfigDouble class which will reset the static properties on the PHPCS native Config class whenever an object created from this class is destroyed.
Explicitly calling the __destruct() method from the AbstractMethodUnitTest::reset() method to ensure it is always run after a test has finished ("after class"), even if there would still be a lingering reference to the object.
This is only a stability tweak, there are no existing tests affected by this issue at this time.
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 theAbstractMethodUnitTest::resetTestFile()
method, but this reset was inadvertently removed with the reasoning that, if all tests use theConfigDouble
, the reset would no longer be needed as theConfigDouble
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, theConfig
class may be left "dirty" after tests using theConfigDouble
, which could break tests.This commit fixes this issue by:
__destruct()
method to theConfigDouble
class which will reset the static properties on the PHPCS nativeConfig
class whenever an object created from this class is destroyed.__destruct()
method from theAbstractMethodUnitTest::reset()
method to ensure it is always run after a test has finished ("after class"), even if there would still be a lingering reference to the object.This is only a stability tweak, there are no existing tests affected by this issue at this time.
Suggested changelog entry
N/A