-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
José Ángel Parada
committed
Jan 10, 2025
1 parent
27002d1
commit 15ad85d
Showing
3 changed files
with
48 additions
and
2 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
46 changes: 46 additions & 0 deletions
46
tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2158Test.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,46 @@ | ||
<?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\BaseTestCase; | ||
|
||
class GH2158Test extends BaseTestCase | ||
{ | ||
public function testDiscriminatorMapCreationType(): void | ||
{ | ||
$obj = new GH2158FirstType(); | ||
$this->dm->persist($obj); | ||
$this->dm->flush(); | ||
|
||
self::assertEquals($this->dm->find(GH2158Abstract::class, $obj->getId()), $obj); | ||
} | ||
} | ||
|
||
#[ODM\Document(collection: 'documents')] | ||
#[ODM\InheritanceType('SINGLE_COLLECTION')] | ||
#[ODM\DiscriminatorField('type')] | ||
#[ODM\DiscriminatorMap([0 => GH2158FirstType::class, 1 => GH2158SecondType::class])] | ||
Check failure on line 25 in tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2158Test.php GitHub Actions / Static Analysis with PHPStan (8.2)
Check failure on line 25 in tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH2158Test.php GitHub Actions / Static Analysis with Psalm (8.2)InvalidArgument
|
||
abstract class GH2158Abstract | ||
{ | ||
/** @var string */ | ||
#[ODM\Id] | ||
protected $id; | ||
|
||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
} | ||
|
||
#[ODM\Document] | ||
class GH2158FirstType extends GH2158Abstract | ||
{ | ||
} | ||
|
||
#[ODM\Document] | ||
class GH2158SecondType extends GH2158Abstract | ||
{ | ||
} |