I started a new project and tried to use Brower & Foundry for the first time in my tests.
I am using the ResetDatabase trait with a SQLite database.
When I run my tests using foundry, I get some deprecation warnings.
I did not found any issue about this so I am not sure if you are already aware about it?
1x: While adding an entity of class App\Entity\Company with an ID hash of "1" to the identity map,
another object of class App\Entity\Company was already present for the same ID. This will trigger
an exception in ORM 3.0.
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.
To opt-in to the new exception, call
\Doctrine\ORM\Configuration::setRejectIdCollisionInIdentityMap on the entity
manager's configuration. (UnitOfWork.php:1696 called by UnitOfWork.php:3923, https://github.com/doctrine/orm/pull/10785, package doctrine/orm)
1x in CompanyResourceTest::test2 from App\Tests\Functional
Maybe ResetDatabase is not clearing the EntityManager after resetting?
database-provided IDs are reassigned after truncating the database without clearing the EntityManager;
Minimum reproducer:
namespace App\Tests\Functional;
use App\Factory\CompanyFactory;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Test\ResetDatabase;
class CompanyResourceTest extends KernelTestCase
{
use ResetDatabase;
public function test1(): void
{
CompanyFactory::createOne();
}
public function test2(): void
{
CompanyFactory::createOne();
}
}
Hello,
I started a new project and tried to use Brower & Foundry for the first time in my tests. I am using the
ResetDatabase
trait with a SQLite database.When I run my tests using foundry, I get some deprecation warnings. I did not found any issue about this so I am not sure if you are already aware about it?
Maybe
ResetDatabase
is not clearing theEntityManager
after resetting?Minimum reproducer: