Skip to content

Commit f2c902e

Browse files
committed
Rewrite test with native lazy ghost
I do not think this needs to be tested on all versions of PHP, using native lazy objects allows us to remove a deprecation.
1 parent 4e5e3c5 commit f2c902e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tests/Tests/ORM/EntityManagerTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
use PHPUnit\Framework\Assert;
2626
use PHPUnit\Framework\Attributes\DataProvider;
2727
use PHPUnit\Framework\Attributes\Group;
28+
use PHPUnit\Framework\Attributes\RequiresPhp;
29+
use ReflectionClass;
2830
use ReflectionProperty;
2931
use stdClass;
30-
use Symfony\Component\VarExporter\LazyGhostTrait;
3132
use TypeError;
3233

3334
class EntityManagerTest extends OrmTestCase
@@ -180,17 +181,12 @@ public function testWrapInTransactionReThrowsThrowables(): void
180181
}
181182

182183
/** Resetting the EntityManager relies on lazy objects until https://github.com/doctrine/orm/issues/5933 is resolved */
184+
#[RequiresPhp('8.4')]
183185
public function testLazyGhostEntityManager(): void
184186
{
185-
$em = new class () extends EntityManager {
186-
use LazyGhostTrait;
187+
$reflector = new ReflectionClass(EntityManager::class);
187188

188-
public function __construct()
189-
{
190-
}
191-
};
192-
193-
$em = $em::createLazyGhost(static function ($em): void {
189+
$em = $reflector->newLazyGhost($initializer = static function (EntityManager $em): void {
194190
$r = new ReflectionProperty(EntityManager::class, 'unitOfWork');
195191
$r->setValue($em, new class () extends UnitOfWork {
196192
public function __construct()
@@ -207,7 +203,7 @@ public function clear(): void
207203
$em->close();
208204
$this->assertFalse($em->isOpen());
209205

210-
$em->resetLazyObject();
206+
$reflector->resetAsLazyGhost($em, $initializer);
211207
$this->assertTrue($em->isOpen());
212208
}
213209

0 commit comments

Comments
 (0)