Merge branch 'fix/#5867-allow-embeddable-usage-in-inheritance-2.5' into 2.5
Close #5867 Close #4097 Close #4277
This commit is contained in:
commit
aa5820309e
@ -940,8 +940,13 @@ class ClassMetadataInfo implements ClassMetadata
|
||||
continue;
|
||||
}
|
||||
|
||||
$parentReflFields[$property] = $reflService->getAccessibleProperty($this->name, $property);
|
||||
$this->reflFields[$property] = $reflService->getAccessibleProperty($this->name, $property);
|
||||
$fieldRefl = $reflService->getAccessibleProperty(
|
||||
isset($embeddedClass['declared']) ? $embeddedClass['declared'] : $this->name,
|
||||
$property
|
||||
);
|
||||
|
||||
$parentReflFields[$property] = $fieldRefl;
|
||||
$this->reflFields[$property] = $fieldRefl;
|
||||
}
|
||||
|
||||
foreach ($this->fieldMappings as $field => $mapping) {
|
||||
|
93
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php
Normal file
93
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3303Test.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
class DDC3303Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->_schemaTool->createSchema([$this->_em->getClassMetadata(DDC3303Employee::CLASSNAME)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group 4097
|
||||
* @group 4277
|
||||
* @group 5867
|
||||
*
|
||||
* When using an embedded field in an inheritance, private properties should also be inherited.
|
||||
*/
|
||||
public function testEmbeddedObjectsAreAlsoInherited()
|
||||
{
|
||||
$employee = new DDC3303Employee(
|
||||
'John Doe',
|
||||
new DDC3303Address('Somewhere', 123, 'Over the rainbow'),
|
||||
'Doctrine Inc'
|
||||
);
|
||||
|
||||
$this->_em->persist($employee);
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
self::assertEquals($employee, $this->_em->find(DDC3303Employee::CLASSNAME, 'John Doe'));
|
||||
}
|
||||
}
|
||||
|
||||
/** @MappedSuperclass */
|
||||
abstract class DDC3303Person
|
||||
{
|
||||
/** @Id @GeneratedValue(strategy="NONE") @Column(type="string") @var string */
|
||||
private $name;
|
||||
|
||||
/** @Embedded(class="DDC3303Address") @var DDC3303Address */
|
||||
private $address;
|
||||
|
||||
public function __construct($name, DDC3303Address $address)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->address = $address;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Embeddable
|
||||
*/
|
||||
class DDC3303Address
|
||||
{
|
||||
/** @Column(type="string") @var string */
|
||||
private $street;
|
||||
|
||||
/** @Column(type="integer") @var int */
|
||||
private $number;
|
||||
|
||||
/** @Column(type="string") @var string */
|
||||
private $city;
|
||||
|
||||
public function __construct($street, $number, $city)
|
||||
{
|
||||
$this->street = $street;
|
||||
$this->number = $number;
|
||||
$this->city = $city;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @Table(name="ddc3303_employee")
|
||||
*/
|
||||
class DDC3303Employee extends DDC3303Person
|
||||
{
|
||||
const CLASSNAME = __CLASS__;
|
||||
|
||||
/** @Column(type="string") @var string */
|
||||
private $company;
|
||||
|
||||
public function __construct($name, DDC3303Address $address, $company)
|
||||
{
|
||||
parent::__construct($name, $address);
|
||||
|
||||
$this->company = $company;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user