From cbab97cc5458109c56da356602f5b5647858be5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Tue, 31 Dec 2024 12:15:56 +0100 Subject: [PATCH] Fix testCreateProxyForDocumentWithUnmappedProperties --- .../MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php b/tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php index 269ebe279..16373cfe4 100644 --- a/tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php +++ b/tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php @@ -9,6 +9,7 @@ use Doctrine\ODM\MongoDB\Event\DocumentNotFoundEventArgs; use Doctrine\ODM\MongoDB\Events; use Doctrine\ODM\MongoDB\LockException; +use Doctrine\ODM\MongoDB\Proxy\InternalProxy; use Doctrine\ODM\MongoDB\Tests\BaseTestCase; use Documents\Cart; use Documents\DocumentWithUnmappedProperties; @@ -16,6 +17,7 @@ use MongoDB\Collection; use MongoDB\Database; use PHPUnit\Framework\MockObject\MockObject; +use ProxyManager\Proxy\GhostObjectInterface; class ProxyFactoryTest extends BaseTestCase { @@ -80,10 +82,14 @@ private function createMockedDocumentManager(): DocumentManager public function testCreateProxyForDocumentWithUnmappedProperties(): void { $proxy = $this->dm->getReference(DocumentWithUnmappedProperties::class, '123'); - self::assertInstanceOf(GhostObjectInterface::class, $proxy); + self::assertTrue(self::isLazyObject($proxy)); - // Disable initialiser so we can access properties without initialising the object - $proxy->setProxyInitializer(null); + // Disable initializer so we can access properties without initialising the object + if ($proxy instanceof InternalProxy) { + $proxy->__setInitialized(true); + } elseif ($proxy instanceof GhostObjectInterface) { + $proxy->setProxyInitializer(null); + } self::assertSame('bar', $proxy->foo); }