Skip to content

Commit cbab97c

Browse files
committed
Fix testCreateProxyForDocumentWithUnmappedProperties
1 parent dbd1f1b commit cbab97c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/Doctrine/ODM/MongoDB/Tests/Proxy/Factory/ProxyFactoryTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
use Doctrine\ODM\MongoDB\Event\DocumentNotFoundEventArgs;
1010
use Doctrine\ODM\MongoDB\Events;
1111
use Doctrine\ODM\MongoDB\LockException;
12+
use Doctrine\ODM\MongoDB\Proxy\InternalProxy;
1213
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
1314
use Documents\Cart;
1415
use Documents\DocumentWithUnmappedProperties;
1516
use MongoDB\Client;
1617
use MongoDB\Collection;
1718
use MongoDB\Database;
1819
use PHPUnit\Framework\MockObject\MockObject;
20+
use ProxyManager\Proxy\GhostObjectInterface;
1921

2022
class ProxyFactoryTest extends BaseTestCase
2123
{
@@ -80,10 +82,14 @@ private function createMockedDocumentManager(): DocumentManager
8082
public function testCreateProxyForDocumentWithUnmappedProperties(): void
8183
{
8284
$proxy = $this->dm->getReference(DocumentWithUnmappedProperties::class, '123');
83-
self::assertInstanceOf(GhostObjectInterface::class, $proxy);
85+
self::assertTrue(self::isLazyObject($proxy));
8486

85-
// Disable initialiser so we can access properties without initialising the object
86-
$proxy->setProxyInitializer(null);
87+
// Disable initializer so we can access properties without initialising the object
88+
if ($proxy instanceof InternalProxy) {
89+
$proxy->__setInitialized(true);
90+
} elseif ($proxy instanceof GhostObjectInterface) {
91+
$proxy->setProxyInitializer(null);
92+
}
8793

8894
self::assertSame('bar', $proxy->foo);
8995
}

0 commit comments

Comments
 (0)