Codeception / module-doctrine

Next gen Doctrine module for Codeception
MIT License
2 stars 1 forks source link

Doctrine2 module and option cleanup does not work #25

Open ihorsamusenko opened 8 years ago

ihorsamusenko commented 8 years ago

I have a functional cest test. In before() I create some entities and I assume they will be deleted during after(), but it does not happen. I dig a little and found that in Codeception\Module\Doctrine2 line 174 there is a PDO exception says "There is no active transaction". And when my second test is ran I entities from first test are still exist

vyarmolenko commented 8 years ago

You experience this issue because the Doctrine service is persisted between tests in a cest. It is the default behaviour. You need to make helper method for cleaning the db between tests and call it in _after(). Please see example solution in https://github.com/Codeception/Codeception/pull/2042#issuecomment-193200443.

I'll prepare an update for Doctrine2 module to include that functionality as it may be widely used in tests.

DavertMik commented 8 years ago

Thanks @vyarmolenko will be waiting for your PR!

szymach commented 7 years ago

Hey, I have recently ran into this issue, but differently. The thing is, the problem only occurred for me with this config:

actor: FunctionalTester
modules:
    enabled:
        - Symfony:
            app_path: 'app'
            var_path: 'var'
            environment: 'test'
        - Doctrine2:
            depends: Symfony2 
        - \Helper\Functional

Switching the dependent module for Doctrine2 to Symfony makes it work all OK. I know this is due to me using the wrong module, but it does not break for Symfony2 and the documentation does not make it clear on which one to use.