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

Database Resetter with Multiple mapper #563

Open
Didixdan opened this issue Feb 20, 2024 · 2 comments
Open

Database Resetter with Multiple mapper #563

Didixdan opened this issue Feb 20, 2024 · 2 comments

Comments

@Didixdan
Copy link

It seems like the Database Resetter does not work well when we have a ODM database and an ORM database.

When i write a functional test and i'm using ResetDatabase trait, the package call DatabaseResetter::resetDatabase which call createORMDatabaseResetter and reset it.

I know it does that because he attempt to create a test database, and got an access denied from the MySQL container (valid behavior because the functional test is only for ODM)

How can i tell Foundry to not reset the database of the ORM connection ? I've found nothing about that in all issues/PR.

@Didixdan
Copy link
Author

For those who wants to have this to work, here is a temporary trait until Foundry work as we want.

namespace App\Traits;

use Doctrine\ODM\MongoDB\DocumentManager;

/**
 * @method static bootKernel()
 */
trait ResetDatabaseODM
{
    public function setUp(): void
    {
        static::bootKernel();
        /** @var DocumentManager $documentManager */
        $documentManager = static::$kernel->getContainer()->get('doctrine_mongodb.odm.document_manager');

        $documentManager->getSchemaManager()->dropDatabases();
    }
}

@nikophil
Copy link
Member

Hello,

you can list the connections/managers you want to reset, thanks to bundle configuration.

You can find an example in the docs here:
https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#database-reset

wouldn't it fix your case to pass it an empty array?

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

No branches or pull requests

2 participants