Skip to content

Commit

Permalink
Fix testCreateProxyForDocumentWithUnmappedProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Dec 31, 2024
1 parent dbd1f1b commit cbab97c
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
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;
use MongoDB\Client;
use MongoDB\Collection;
use MongoDB\Database;
use PHPUnit\Framework\MockObject\MockObject;
use ProxyManager\Proxy\GhostObjectInterface;

class ProxyFactoryTest extends BaseTestCase
{
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit cbab97c

Please sign in to comment.