LiipTestFixturesBundle icon indicating copy to clipboard operation
LiipTestFixturesBundle copied to clipboard

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

Open Chris53897 opened this issue 1 year ago • 5 comments

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

Chris53897 avatar Feb 04 '24 21:02 Chris53897

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.

Chris53897 avatar Feb 17 '24 10:02 Chris53897

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.

mbabker avatar Feb 19 '24 15:02 mbabker

@mbabker Thanks for the input.

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

Chris53897 avatar Feb 19 '24 16:02 Chris53897

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

Chris53897 avatar Feb 22 '24 09:02 Chris53897

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?

Chris53897 avatar Mar 02 '24 19:03 Chris53897

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:

  • #272

alexislefebvre avatar Mar 10 '24 17:03 alexislefebvre

I think it has been partially fixed by this PR:

  • #296

doctrine/dbal 4 is not supported yet.

alexislefebvre avatar Mar 31 '24 16:03 alexislefebvre

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

Chris53897 avatar Mar 31 '24 18:03 Chris53897