Problem with doctrine connections #3479

Closed
j-velasco opened this Issue Sep 2, 2016 · 8 comments

Comments

Projects
None yet
2 participants
@j-velasco

We are currently using version 2.0 of Codeception, however we want to upgrade to the latest version (2.2) that supports PHPUnit 5.
We have some code we use Doctrine's entity manager for persisting, but for reading we make use of the Doctrine's connection. It seems that in this situation when using Codeception v2.1 and v2.2, the Doctrine's entity manager uses one connection and Doctrine's connection a different one. You can see this repo https://github.com/kooso/codeception_doctrine_bug_example on how to reproduce it.

Here is the sample output from the example repo above:

  • In version 2.0 all the queries run inside of the same transaction and all works fine
  • In version 2.1 and 2.2 (master in that repo), we can see that a new connection happens in the middle causing that the select doesn't see the changes from insert

@Naktibalda Naktibalda added the Doctrine label Sep 3, 2016

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 4, 2016

Member

Could you git bisect 2.1 branch of Codeception and identify commit which caused this change?

Member

Naktibalda commented Sep 4, 2016

Could you git bisect 2.1 branch of Codeception and identify commit which caused this change?

@j-velasco

This comment has been minimized.

Show comment
Hide comment
@j-velasco

j-velasco Sep 4, 2016

Hi, thanks for your fast response.

I just did it and seems to be this commit eedd32c

Hi, thanks for your fast response.

I just did it and seems to be this commit eedd32c

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 4, 2016

Member

Use the new http://codeception.com/docs/modules/Symfony#persistService method to persist doctrine.dbal.backend_connection between requests and/or tests.

Member

Naktibalda commented Sep 4, 2016

Use the new http://codeception.com/docs/modules/Symfony#persistService method to persist doctrine.dbal.backend_connection between requests and/or tests.

@j-velasco

This comment has been minimized.

Show comment
Hide comment
@j-velasco

j-velasco Sep 5, 2016

@Naktibalda that doesn't solve the problem, I just tried in the repo example calling $this->integration->persistService('doctrine.dbal.backend_connection', true) from _before method and the behaviour its the same, should I call it from somewhere else?

@Naktibalda that doesn't solve the problem, I just tried in the repo example calling $this->integration->persistService('doctrine.dbal.backend_connection', true) from _before method and the behaviour its the same, should I call it from somewhere else?

@Naktibalda Naktibalda added the Symfony label Sep 5, 2016

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 5, 2016

Member

Try adding it to _getEntityManager()

Member

Naktibalda commented Sep 5, 2016

Try adding it to _getEntityManager()

@j-velasco

This comment has been minimized.

Show comment
Hide comment
@j-velasco

j-velasco Sep 6, 2016

@Naktibalda sorry for comming late. That make my tests pass

j-velasco commented Sep 6, 2016

@Naktibalda sorry for comming late. That make my tests pass

@j-velasco

This comment has been minimized.

Show comment
Hide comment
@j-velasco

j-velasco Sep 6, 2016

Thanks for all your help @Naktibalda, for now I have my test passing, but the solution is still a little hacky, here you can see how the solution looks like. It's there a better way to solve it? Makes sense that Symfony module to persist all doctrine connections? or could Symfony module accept a config with services to persist?

j-velasco commented Sep 6, 2016

Thanks for all your help @Naktibalda, for now I have my test passing, but the solution is still a little hacky, here you can see how the solution looks like. It's there a better way to solve it? Makes sense that Symfony module to persist all doctrine connections? or could Symfony module accept a config with services to persist?

@Naktibalda

This comment has been minimized.

Show comment
Hide comment
@Naktibalda

Naktibalda Sep 6, 2016

Member

Please add this service to Symfony module and make a pull request.

Member

Naktibalda commented Sep 6, 2016

Please add this service to Symfony module and make a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment