liip / LiipTestFixturesBundle

This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications
https://liip.ch
MIT License
165 stars 45 forks source link

feat: allow doctrine/orm 3, doctrine/dbal 4 (WIP) #265

Closed Chris53897 closed 5 months ago

Chris53897 commented 7 months ago

jackalope/jackalope-doctrine-dbal does not yet support dbal 4 (but they are working on it)

Chris53897 commented 7 months ago

Now an installable set is available.

There are multiple errors. One is this, that change was intoduced in doctrine/orm 2.16.x (later removed) and reintoduced in 3.x. If someone knows how to fix it, please let me know.

Doctrine\ORM\Exception\EntityIdentityCollisionException: While adding an entity of class Liip\Acme\Tests\App\Entity\User with an ID hash of "1" to the identity map,
   │ another object of class Liip\Acme\Tests\App\Entity\User was already present for the same ID. This exception
   │ is a safeguard against an internal inconsistency - IDs should uniquely map to
   │ entity object instances. This problem may occur if:
   │
   │ - you use application-provided IDs and reuse ID values;
   │ - database-provided IDs are reassigned after truncating the database without
   │ clearing the EntityManager;
   │ - you might have been using EntityManager#getReference() to create a reference
   │ for a nonexistent ID that was subsequently (by the RDBMS) assigned to another
   │ entity.
   │
   │ Otherwise, it might be an ORM-internal inconsistency, please report it.
mbabker commented 6 months ago

One is this, that change was intoduced in doctrine/orm 2.16.x (later removed) and reintoduced in 3.x. If someone knows how to fix it, please let me know.

Just looking at the test fixtures, I don't have a good solution here. But, all the setId() calls are probably what is causing the ORM's identity map exception. If the tests can be updated in a way that they don't rely on specific primary key values then that would be the best course of action.

Chris53897 commented 6 months ago

@mbabker Thanks for the input.

My primary goal is to test my bundle via this bundle ;)

Chris53897 commented 6 months ago

I will come back to this as soon, as i have some free time.

Chris53897 commented 6 months ago

I did split the PRs https://github.com/liip/LiipTestFixturesBundle/pull/269 and https://github.com/liip/LiipTestFixturesBundle/pull/268

After that is merged, maybe just simpify things and https://github.com/liip/LiipTestFixturesBundle/issues/272 and add support for doctrine/orm 3, doctrine/dbal 4 after that?

alexislefebvre commented 6 months ago

You can rebase it on 2.x.

Or apply these changes from the 3.x branch and target this branch when creating another PR, see:

alexislefebvre commented 5 months ago

I think it has been partially fixed by this PR:

doctrine/dbal 4 is not supported yet.

Chris53897 commented 5 months ago

thanks @alexislefebvre I did rebase against 2.x. There are no useful changes in this PR anymore. I will close this PR.