1
0
mirror of synced 2025-01-20 07:21:40 +03:00

86 lines
2.2 KiB
PHP
Raw Normal View History

2014-10-18 18:00:34 +02:00
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Tools\ResolveTargetEntityListener;
2014-10-18 18:00:34 +02:00
/**
* @group DDC-3300
*/
class DDC3300Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
public function testResolveTargetEntitiesChangesDiscriminatorMapValues()
2014-10-18 18:00:34 +02:00
{
$resolveTargetEntity = new ResolveTargetEntityListener();
$resolveTargetEntity->addResolveTargetEntity(
DDC3300BossInterface::INTERFACENAME,
DDC3300Boss::CLASSNAME,
array()
);
$resolveTargetEntity->addResolveTargetEntity(
DDC3300EmployeeInterface::INTERFACENAME,
DDC3300Employee::CLASSNAME,
array()
);
$this->_em->getEventManager()->addEventSubscriber($resolveTargetEntity);
2014-10-18 18:00:34 +02:00
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(DDC3300Person::CLASSNAME),
2014-10-18 18:00:34 +02:00
));
$boss = new DDC3300Boss();
$employee = new DDC3300Employee();
$this->_em->persist($boss);
$this->_em->persist($employee);
2014-10-18 18:00:34 +02:00
$this->_em->flush();
$this->_em->clear();
$this->assertEquals($boss, $this->_em->find(DDC3300BossInterface::INTERFACENAME, $boss->id));
$this->assertEquals($employee, $this->_em->find(DDC3300EmployeeInterface::INTERFACENAME, $employee->id));
2014-10-18 18:00:34 +02:00
}
}
/**
* @Entity
* @InheritanceType("SINGLE_TABLE")
* @DdiscriminatorColumn(name="discr", type="string")
* @DiscriminatorMap({
2015-01-15 04:02:39 +01:00
* "boss" = "Doctrine\Tests\ORM\Functional\Ticket\DDC3300BossInterface",
2014-10-18 18:00:34 +02:00
* "employee" = "Doctrine\Tests\ORM\Functional\Ticket\DDC3300EmployeeInterface"
* })
*/
abstract class DDC3300Person
{
const CLASSNAME = __CLASS__;
2015-01-15 04:02:39 +01:00
/** @Id @Column(type="integer") @GeneratedValue(strategy="AUTO") */
2014-10-18 18:00:34 +02:00
public $id;
}
interface DDC3300BossInterface
{
const INTERFACENAME = __CLASS__;
2014-10-18 18:00:34 +02:00
}
2015-01-15 04:02:39 +01:00
/** @Entity */
2014-10-18 18:00:34 +02:00
class DDC3300Boss extends DDC3300Person implements DDC3300BossInterface
{
const CLASSNAME = __CLASS__;
2014-10-18 18:00:34 +02:00
}
interface DDC3300EmployeeInterface
{
const INTERFACENAME = __CLASS__;
2014-10-18 18:00:34 +02:00
}
2015-01-15 04:02:39 +01:00
/** @Entity */
2014-10-18 18:00:34 +02:00
class DDC3300Employee extends DDC3300Person implements DDC3300EmployeeInterface
{
const CLASSNAME = __CLASS__;
2014-10-18 18:00:34 +02:00
}