doctrine / data-fixtures

Doctrine2 ORM Data Fixtures Extensions
http://www.doctrine-project.org
MIT License
2.76k stars 224 forks source link

Cant use an entity with ReferenceRepository if its name ends with Proxy #417

Closed mdevlamynck closed 1 year ago

mdevlamynck commented 1 year ago

Since v1.6.0 our tests fail when loading fixtures for entities with a Proxy suffix in their name.

For example with the entity Path\To\Entities\EntityProxy we get a Doctrine\Persistence\Mapping\MappingException: Class 'Path\To\Entities\Entity' does not exist error.

I think the bug was introduced in https://github.com/doctrine/data-fixtures/pull/409. The getRealClass removes the Proxy suffix. Maybe the check to remove the suffix Proxy could be made more specific to actual proxies?

greg0ire commented 1 year ago

Cc @VincentLanglet

VincentLanglet commented 1 year ago

Maybe the custom getRealClass implementation should be replaced by Doctrine\Common\Util\ClassUtils::getRealClass()

mdevlamynck commented 1 year ago

I just tried it indeed fixes the issue. I'll make a PR, thx :)

greg0ire commented 1 year ago

This library does not have a dependency on doctrine/common, and I don't think we want to introduce one (we're trying to get rid of doctrine/common entirely).

mdevlamynck commented 1 year ago

You prefer simply copying the code of ClassUtils::getRealClass() in this project?

greg0ire commented 1 year ago

I guess