Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a functional test covering #8127 #10388

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH8127Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Tests\OrmFunctionalTestCase;

class GH8127Test extends OrmFunctionalTestCase
{
protected function setUp(): void
{
parent::setUp();

$this->createSchemaForModels(
GH8127Root::class,
GH8127Middle::class,
GH8127Leaf::class
);
}

/**
* @dataProvider queryClasses
*/
public function testLoadFieldsFromAllClassesInHierarchy(string $queryClass): void
{
$entity = new GH8127Leaf();
$entity->root = 'root';
$entity->middle = 'middle';
$entity->leaf = 'leaf';

$this->_em->persist($entity);
$this->_em->flush();
$this->_em->clear();

$loadedEntity = $this->_em->find(GH8127Root::class, $entity->id);

self::assertSame('root', $loadedEntity->root);
self::assertSame('middle', $loadedEntity->middle);
self::assertSame('leaf', $loadedEntity->leaf);
}

public function queryClasses(): array
{
return [
'query via root entity' => [GH8127Root::class],
'query via leaf entity' => [GH8127Leaf::class],
];
}
}

/**
* @ORM\Entity
* @ORM\Table(name="root")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorMap({ "root": "GH8127Root", "middle": "GH8127Middle", "leaf": "GH8127Leaf"})
*/
abstract class GH8127Root
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*
* @var int
*/
public $id;

/**
* @ORM\Column
*
* @var string
*/
public $root;
}

/**
* @ORM\Entity
*/
abstract class GH8127Middle extends GH8127Root
{
/**
* @ORM\Column
*
* @var string
*/
public $middle;
}

/**
* @ORM\Entity
*/
class GH8127Leaf extends GH8127Middle
{
/**
* @ORM\Column
*
* @var string
*/
public $leaf;
}