doctrine/mongodb-odm

Mapping validation does not validate targetDocument

buffcode opened this issue · 0 comments

Bug Report

Q A
BC Break maybe
Version 2.5.x

Summary

Validity of EmbedOne/EmbedMany/ReferenceOne/ReferenceMany with targetDocument is not confirmed.

Current behavior

Running doctrine:mongodb:mapping:info or just warming up the ClassMetadata does not detect references within EmbedOne/EmbedMany/ReferenceOne/ReferenceMany to targetDocuments that cannot be resolved.

How to reproduce

/** @ODM\Document */
class InvalidTargetDocumentTestDocument
{
    /**
     * @ODM\Id
     *
     * @var string|null
     */
    public $id;

    /**
     * @ODM\ReferenceOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass::class)
     *
     * @var object|null
     */
    public $reference;
}

Expected behavior

ClassMetadata generation should fail or doctrine:mongodb:mapping:info should display an error.