zenstruck / foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html
MIT License
607 stars 62 forks source link

test: add test with multiple ORM schemas #629

Closed vincentchalamon closed 1 week ago

vincentchalamon commented 2 weeks ago

Fixes #618

vincentchalamon commented 2 weeks ago

Hi @kbond,

Regarding the failing CI (I'm not familiar with multiple schemas). Do you know what's going on there?

The doctrine:schema:update command doesn't seem to support multiple schemas. To handle such specific use case, I had to separate migrate mode from schema mode fixtures. Push in progress.

This PR is still in WIP till I find a clean solution to test this specific use case.

nikophil commented 1 week ago

Hi @vincentchalamon

I'm wondering if a simpler solution would not be to declare two entity managers, affect one entity to this entity manager, and configure the test kernel to not reset this specific EM. WDYT?

vincentchalamon commented 1 week ago

Hi @vincentchalamon

I'm wondering if a simpler solution would not be to declare two entity managers, affect one entity to this entity manager, and configure the test kernel to not reset this specific EM. WDYT?

I'm afraid using multiple entity managers won't solve the original issue. The idea is to add non-regression tests to ensure the database is fully and properly removed before running the migrations (cf. https://github.com/zenstruck/foundry/pull/615).

The idea here is to have a custom migration which should fail the tests if not run properly (for instance, if AbstractORMPersistenceStrategy::resetSchema method is updated).

nikophil commented 1 week ago

ok thanks for explanations, I understand better now!