-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using ResetDatabase with DamaDoctrineTestBundle and Symfony Messenger with Doctrine #757
Comments
few questions:
|
Yes, I'm using the dama/doctrine-test-bundle. Commenting those lines solves the reported error ... but causes this other error that prevents running any tests:
|
I think I see where all of this is coming from: for PostgreSQL, we need to drop all other connections to the db (for example, any sql client which is connected to it) in order to be able to drop/recreate the connection. But if we do this, doctrine-messenger breaks when we call On the other hand, if we don't drop all other connections, the connection from doctrine-messenger prevents to recreate the connection. This was your second problem, when you commented the code. And the real error is hidden by the message " I think we'll need to reproduce this in our CI, and see how everything can work together. and, by the way:
actually, in #658 the problem was between activating dama, and shutting down the kernel, and it was fixed inside #690 - the fix was not the extension mechanism, but a consequence of its implementation :) |
@javiereguiluz I don't manage to reproduce your problem in our testsuite. In which context do you have your problem? do you have a I manage to dispatch a message with doctrine transport in a kernel test case, even when using database reset 🤔 |
@nikophil sadly I won't have time to create a reproducer for this. but, I could fix it with the following change: So, we're now using in the project my Foundry fork with that change. Do you know if there's some way to completely disable that DB reset logic without adding that |
ok, no problem. If at some point you have some time for this, I'd be willing to know what's going on and fix it in Foundry!
yeah totally, you can decorate #[When('test')]
#[AsDecorator(OrmResetter::class)]
final readonly class DecorateDatabaseResetter implements OrmResetter
{
public function __construct(
private OrmResetter $decorated
) {}
public function resetBeforeFirstTest(KernelInterface $kernel): void
{
// maybe do nothing here? or just call `doctrine:schema:update`?
}
public function resetBeforeEachTest(KernelInterface $kernel): void
{
$this->decorated->resetBeforeEachTest($kernel);
}
} |
@nikophil your proposed solution worked beautifully, so we no longer need to use the fork. Thanks a lot. Also, I started using this bundle just a few days ago. This error could totally be something related to bad configuration or usage on my side. So, let's close this issue for now as fixed. If other folks face the same issue, maybe they can add a comment here or create a new issue with a reproducer. Thanks! |
@nikophil a quick update about this. I just finished updating all our existing tests to Foundry and the reported error is gone. We no longer need to decorate So, this "bug" is not really a bug and was caused for mixing Foundry and non-Foundry tests and for my lack of Foundry skills. Luckily, I'm improving at this 💪 |
I'm facing the same issue that was reported in #658.
When using database reset, I see a lot of errors like this one:
I'm using PostgreSQL for the database and these packages:
The solution proposed in #658 is an extension mechanism that it's documented here: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#extending-reset-mechanism
But, I don't know how to use that to solve the reported issue. Did anyone find any solution to this? Thanks!
The text was updated successfully, but these errors were encountered: