Skip to content

Commit

Permalink
Merge pull request doctrine#1991 from alcaeus/fix-invalid-proxy-gener…
Browse files Browse the repository at this point in the history
…ation

Fix generation of proxy classes
  • Loading branch information
alcaeus authored Apr 4, 2019
2 parents f896ed4 + f61536f commit f61d90b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function generateProxyClasses(array $classes) : int
static function () {
// empty closure, serves its purpose, for now
},
$this->skippedFieldsFqns($metadata)
[
'skippedProperties' => $this->skippedFieldsFqns($metadata),
]
);
}

Expand Down
51 changes: 51 additions & 0 deletions tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Doctrine\ODM\MongoDB\Tests\BaseTest;

class GH1990Test extends BaseTest
{
public function testInitialisationOfInverseProxy() : void
{
// Generate proxy class using generateProxyClasses to ensure it is
// consistent with other proxy classes
$metadata = $this->dm->getClassMetadata(GH1990Document::class);
$this->dm->getProxyFactory()->generateProxyClasses([$metadata]);

$parent = new GH1990Document(null);
$child = new GH1990Document($parent);
$this->dm->persist($parent);
$this->dm->persist($child);

$this->dm->flush();
$this->dm->clear();

$this->dm->find(GH1990Document::class, $child->getId());

self::assertInstanceOf(GH1990Document::class, $child);
}
}

/** @ODM\Document */
class GH1990Document
{
/** @ODM\Id */
private $id;

/** @ODM\ReferenceOne(targetDocument=GH1990Document::class) */
private $parent;

public function __construct(?GH1990Document $parent)
{
$this->parent = $parent;
}

public function getId() : ?string
{
return $this->id;
}
}

0 comments on commit f61d90b

Please sign in to comment.