-
-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge release 2.5.5 into 2.6.x (#2585)
* fix: Do not drop/re-create 2dsphere indexes (#2575) * Validate that targetDocument can be resolved (#2577) * fix: Validate that targetDocument can be resolved * refactor: Use exception factory * fix: Validate that all values in a discriminatorMap can be resolved * fix: PHPStan errors for intentionally missing class * fix: psalm/phpunit CI tests --------- Co-authored-by: buffcode <[email protected]> Co-authored-by: Andreas Braun <[email protected]>
- Loading branch information
1 parent
99aa043
commit 66a6f3f
Showing
7 changed files
with
197 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
tests/Doctrine/ODM/MongoDB/Tests/Functional/TargetDocumentTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ODM\MongoDB\Tests\Functional; | ||
|
||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
use Doctrine\ODM\MongoDB\Mapping\MappingException; | ||
use Doctrine\ODM\MongoDB\Tests\BaseTestCase; | ||
use stdClass; | ||
|
||
class TargetDocumentTest extends BaseTestCase | ||
{ | ||
/** @doesNotPerformAssertions */ | ||
public function testMappedSuperClassAsTargetDocument(): void | ||
{ | ||
$test = new TargetDocumentTestDocument(); | ||
$test->reference = new TargetDocumentTestReference(); | ||
$this->dm->persist($test); | ||
$this->dm->persist($test->reference); | ||
$this->dm->flush(); | ||
} | ||
|
||
public function testTargetDocumentIsResolvable(): void | ||
{ | ||
self::expectExceptionObject( | ||
MappingException::invalidTargetDocument( | ||
'Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass', | ||
InvalidTargetDocumentTestDocument::class, | ||
'reference', | ||
), | ||
); | ||
|
||
$test = new InvalidTargetDocumentTestDocument(); | ||
$test->reference = new stdClass(); | ||
$this->dm->persist($test); | ||
} | ||
|
||
public function testDiscriminatorTargetIsResolvable(): void | ||
{ | ||
self::expectExceptionObject( | ||
MappingException::invalidClassInReferenceDiscriminatorMap( | ||
'Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass', | ||
InvalidDiscriminatorTargetsTestDocument::class, | ||
'reference', | ||
), | ||
); | ||
|
||
$test = new InvalidDiscriminatorTargetsTestDocument(); | ||
$test->reference = new stdClass(); | ||
$this->dm->persist($test); | ||
} | ||
} | ||
|
||
/** @ODM\Document */ | ||
class TargetDocumentTestDocument | ||
{ | ||
/** | ||
* @ODM\Id | ||
* | ||
* @var string|null | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ODM\ReferenceOne(targetDocument=Doctrine\ODM\MongoDB\Tests\Functional\TargetDocumentTestReference::class) | ||
* | ||
* @var TargetDocumentTestReference|null | ||
*/ | ||
public $reference; | ||
} | ||
|
||
/** @ODM\MappedSuperclass */ | ||
abstract class AbstractTargetDocumentTestReference | ||
{ | ||
/** | ||
* @ODM\Id | ||
* | ||
* @var string|null | ||
*/ | ||
public $id; | ||
} | ||
|
||
/** @ODM\Document */ | ||
class TargetDocumentTestReference extends AbstractTargetDocumentTestReference | ||
{ | ||
} | ||
|
||
/** @ODM\Document */ | ||
class InvalidTargetDocumentTestDocument | ||
{ | ||
/** | ||
* @ODM\Id | ||
* | ||
* @var string|null | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ODM\ReferenceOne(targetDocument="Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass") | ||
* | ||
* @var object|null | ||
*/ | ||
public $reference; | ||
} | ||
|
||
|
||
/** @ODM\Document */ | ||
class InvalidDiscriminatorTargetsTestDocument | ||
{ | ||
/** | ||
* @ODM\Id | ||
* | ||
* @var string|null | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* @ODM\ReferenceOne(discriminatorField="referencedClass", discriminatorMap={"Foo"="Doctrine\ODM\MongoDB\Tests\Functional\SomeInvalidClass"}) | ||
* | ||
* @var object|null | ||
*/ | ||
public $reference; | ||
} |
56 changes: 0 additions & 56 deletions
56
tests/Doctrine/ODM/MongoDB/Tests/Functional/TestTargetDocument.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters