Closed hijhem closed 2 years ago
Thanks for the report!
Are you up for creating a PR with a test case here https://github.com/codeception/yii2-tests? And a PR with the fix you propose here?
FYI. I have encountered with too many connections in functional tests. New DB connection opens on every test request like $tester->sendGet()
and stay opened untill all tests finish.
I see that \Codeception\Module\Yii2::_after use connectionWatcher to close all connections in case of simple unit tests. But in case of functional tests \Codeception\Lib\Connector\Yii2::doRequest doesn't use connectionWatcher. I dont know why but connections here are not closed even if recreateApplication = true.
It works for functional tests as well. Are you having the same issue as OP? If not create a separate issue.
Closing this since OP has not been responsive and clearly it's only an issue in a small subset of cases.
What are you trying to achieve?
Running large suite of unit tests
What do you get instead?
After some investigation I found that ConnectionWatcher doesn't close connections initialized by the application.
That happens because connection is being opened as soon as application starts (bootstraping some settings) and ConnectionWatcher doesn't catch it.
However, if I place ConnectionWatcher initialization before the app initialization, problem disappears.
Details