Skip to content
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

How to detect dama wrapper is active ? #295

Closed
Kytrix opened this issue May 13, 2024 · 4 comments
Closed

How to detect dama wrapper is active ? #295

Kytrix opened this issue May 13, 2024 · 4 comments

Comments

@Kytrix
Copy link

Kytrix commented May 13, 2024

Hello,
I previously used a test inside my ancestor test class constructor:
if(!$this->em->getConnection()->isTransactionActive())
$this->fail("No active transaction ! you could lost data !\n");

But it seems to not work with lasts versions.

I made another test by looking in Connection params.

I try to get the driver class, but because the wrapperDriver is private I'm not able to test it's class, despite my debugger is able to see it :
image

Is there a better solution ?

@dmaicher
Copy link
Owner

Out of curiosity: why would you need to detect if the bundle is managing a connection? 🤔

@Kytrix
Copy link
Author

Kytrix commented May 17, 2024

Because I already have the issue of the tests were running without transaction (the bundle was somehow been disabled) and I don't want this could append again.

@dmaicher
Copy link
Owner

You could try

/** @var \PDO $connection */
$connection = $this->em->getConnection()->getNativeConnection();
if(!$connection->inTransaction()) {
    $this->fail("No active transaction ! you could lost data !\n");
}

@Kytrix
Copy link
Author

Kytrix commented May 22, 2024

Thank you very much ! it works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants