Open Jurigag opened 2 years ago
Resetting services is not really feasible, without making individual services resettable via proxies :thinking:
At some point me and others in then zend framework community tried to use same application to handle multiple consecutive requests. We doscovered that application was leaking state between requests pretty badly in unpredictable manner.
I do not think application can be reliably reset for testing purposes for much the same reasons it couldn't be used for multiple requests.
Biggest issue being that the controller helpers and view helpers are stateful by design too.
Services being resettable is feasible with some work, but that would require expanding the laminas/laminas-servicemanager
capabilities substantially.
Feature Request
So, currently in laminas-test a reset of test is done just by initialization of whole application again which in big codebase can take a huge amount of time, with creating container, reading configs etc.
Most of other frameworks works pretty fine with typical request-response loop, like you can execute multiple request on application itself and it will return proper responses. Tried the same here when using laminas-test while keeping the same application instance - not possible, the second request to same endpoint doesn't go to the controller.
Not sure actually if this is a bug or feature request, but it could be good to somehow clear/reset event dispatcher of application without recreating and bootsraping whole container once again.