You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The base class defines the @before and @after methods that will prepare and clean up the test database and the connection.
The specific test cases may define their own setup and teardown procedures.
There is a problem in the TearDownFailureTest that it may get skipped but it doesn't check (and probably can't) if it was skipped, it attempts to perform the teardown logic and throws the exception that gets suppressed by the test runner. Because of that, the disconnect() method in the parent class doesn't get called and the test instance remains connected to the database leaking resources.
It wouldn't be a problem if the test object got destroyed after the run but it doesn't (there are a few reported issues about that, e.g. #3039).
If the teardown methods are meant for the cleanup, should they be called independently on the results of each other? Currently, an exception stops the chain:
Take this test for example:
The code above does the following:
@before
and@after
methods that will prepare and clean up the test database and the connection.There is a problem in the
TearDownFailureTest
that it may get skipped but it doesn't check (and probably can't) if it was skipped, it attempts to perform the teardown logic and throws the exception that gets suppressed by the test runner. Because of that, thedisconnect()
method in the parent class doesn't get called and the test instance remains connected to the database leaking resources.It wouldn't be a problem if the test object got destroyed after the run but it doesn't (there are a few reported issues about that, e.g. #3039).
If the teardown methods are meant for the cleanup, should they be called independently on the results of each other? Currently, an exception stops the chain:
phpunit/src/Framework/TestCase.php
Lines 919 to 924 in 8053bc6
Currently, the desired logic could be implemented in a
TestListener
class which has access to theTest
object but it's deprecated:phpunit/src/Framework/TestListener.php
Line 37 in 5a95748
Neither the deprecated
TestHook
API, nor the event-based API seem to provide access to theTest
instance for reliable cleanup.The text was updated successfully, but these errors were encountered: