Skip to content

Commit 9937a0e

Browse files
committed
move test to avoid weird issue with unit of work and php 8 ?
1 parent 98c0c61 commit 9937a0e

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

tests/Bridge/Doctrine/Persister/ObjectManagerPersisterTest.php

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function setUp(): void
7777
*/
7878
public function tearDown(): void
7979
{
80-
$this->entityManager->getUnitOfWork()->clear();
8180
$this->purger->purge();
8281
}
8382

@@ -114,6 +113,28 @@ public function testCanPersistAnEntity($entity, bool $exact = false)
114113
}
115114
}
116115

116+
public function testCanPersistEntitiesWithoutExplicitIdentifierSetEvenWhenExistingEntitiesHaveOne()
117+
{
118+
$dummy1 = new Dummy();
119+
$this->entityManager->persist($dummy1);
120+
$this->entityManager->flush();
121+
122+
// When loading fixtures in real world and existing entity can be persisted again by the persister.
123+
// e.g. when this entity has been persisted by a relation with the cascade persist option.
124+
$this->persister->persist($dummy1);
125+
126+
$dummy2 = new Dummy();
127+
$this->persister->persist($dummy2);
128+
129+
$this->persister->flush();
130+
131+
$entity = $this->entityManager->getRepository(Dummy::class)->find($dummy1->id);
132+
$this->assertInstanceOf(Dummy::class, $entity);
133+
134+
$entity = $this->entityManager->getRepository(Dummy::class)->find($dummy2->id);
135+
$this->assertInstanceOf(Dummy::class, $entity);
136+
}
137+
117138
public function testCanPersistAnEntityWithRelationsAndExplicitIds()
118139
{
119140
$dummy = new DummyWithIdentifier();
@@ -170,28 +191,6 @@ public function testCanPersistMultipleEntitiesWithExplicitIdentifierSet()
170191
$this->assertInstanceOf(DummyWithIdentifier::class, $entity);
171192
}
172193

173-
public function testCanPersistEntitiesWithoutExplicitIdentifierSetEvenWhenExistingEntitiesHaveOne()
174-
{
175-
$dummy1 = new Dummy();
176-
$this->entityManager->persist($dummy1);
177-
$this->entityManager->flush();
178-
179-
// When loading fixtures in real world and existing entity can be persisted again by the persister.
180-
// e.g. when this entity has been persisted by a relation with the cascade persist option.
181-
$this->persister->persist($dummy1);
182-
183-
$dummy2 = new Dummy();
184-
$this->persister->persist($dummy2);
185-
186-
$this->persister->flush();
187-
188-
$entity = $this->entityManager->getRepository(Dummy::class)->find($dummy1->id);
189-
$this->assertInstanceOf(Dummy::class, $entity);
190-
191-
$entity = $this->entityManager->getRepository(Dummy::class)->find($dummy2->id);
192-
$this->assertInstanceOf(Dummy::class, $entity);
193-
}
194-
195194
public function testPersistingMultipleEntitiesWithAndWithoutExplicitIdentifierSetWillNotThrowORMException()
196195
{
197196
$dummy = new DummyWithIdentifier();

0 commit comments

Comments
 (0)