I am trying to simulate a multi-site environment in an integration test with phpunit. I know how to init a new database connection with
Database::addConnectionInfo but how can I cleanly switch the database used by the current environment?
Database::setActiveConnection will only work for SQL queries but I would like to use the entity_type.manager service and the only way I found is to replace the database service in the container and call
KernelTest::setUp. Switching back an forth between the databases is still pretty buggy and complex.