3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4 use Doctrine\ORM\UnitOfWork;
6 require_once __DIR__ . '/../../../TestInit.php';
11 class DDC1383Test extends \Doctrine\Tests\OrmFunctionalTestCase
13 protected function setUp()
18 $this->_schemaTool->createSchema(array(
19 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383AbstractEntity'),
20 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1383Entity'),
22 } catch(\Exception $ignored) {}
25 public function testFailingCase()
27 $parent = new DDC1383Entity();
28 $child = new DDC1383Entity();
30 $child->setReference($parent);
32 $this->_em->persist($parent);
33 $this->_em->persist($child);
35 $id = $child->getId();
40 // Try merging the parent entity
41 $child = $this->_em->merge($child);
42 $parent = $child->getReference();
44 // Parent is not instance of the abstract class
45 self::assertTrue($parent instanceof DDC1383AbstractEntity,
46 "Entity class is " . get_class($parent) . ', "DDC1383AbstractEntity" was expected');
48 // Parent is NOT instance of entity
49 self::assertTrue($parent instanceof DDC1383Entity,
50 "Entity class is " . get_class($parent) . ', "DDC1383Entity" was expected');
56 * @InheritanceType("JOINED")
57 * @DiscriminatorColumn(name="discr", type="integer")
58 * @DiscriminatorMap({1 = "DDC1383Entity"})
60 abstract class DDC1383AbstractEntity
64 * @Column(type="integer")
69 public function getId()
74 public function setId($id)
83 class DDC1383Entity extends DDC1383AbstractEntity
86 * @ManyToOne(targetEntity="DDC1383AbstractEntity")
90 public function getReference()
92 return $this->reference;
95 public function setReference(DDC1383AbstractEntity $reference)
97 $this->reference = $reference;