1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\Tests\Models\OneToOneSingleTableInheritance\Cat;
use Doctrine\Tests\Models\OneToOneSingleTableInheritance\LitterBox;
use Doctrine\Tests\Models\OneToOneSingleTableInheritance\Pet;
use Doctrine\Tests\OrmFunctionalTestCase;
use PHPUnit\Framework\Attributes\Group;
use function assert;
class OneToOneSingleTableInheritanceTest extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();
$this->createSchemaForModels(
Pet::class,
Cat::class,
LitterBox::class,
);
}
/**
* Tests a unidirectional one-to-one association mapping from an inheritance child class
*/
#[Group('DDC-3517')]
#[Group('#1265')]
public function testFindFromOneToOneOwningSideJoinedTableInheritance(): void
{
$cat = new Cat();
$cat->litterBox = new LitterBox();
$this->_em->persist($cat);
$this->_em->persist($cat->litterBox);
$this->_em->flush();
$this->_em->clear();
$foundCat = $this->_em->find(Pet::class, $cat->id);
assert($foundCat instanceof Cat);
self::assertInstanceOf(Cat::class, $foundCat);
self::assertSame($cat->id, $foundCat->id);
self::assertInstanceOf(LitterBox::class, $foundCat->litterBox);
self::assertSame($cat->litterBox->id, $foundCat->litterBox->id);
}
}
|