I'm using doctrine my tests, and sometimes I want to test an UNIQUE exception, relying that doctrine will give me the proper one. But after getting this kind of exceptions from doctrine the entity manager is closed and I cant continue to test with it. For now I'm getting a new one and updating the classes that uses it, but this is far from ideal - the setup is too large and the performance is penalized. I know an alternative would be to use mocks but it would be far too complicated IMO. Maybe controlling the flush, but it seems too much work as well.
Do you have any insights on this?