-
-
Save doctrinebot/f9bf6e2d281a60efd056 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-500 - https://github.com/doctrine/doctrine2/issues/5007
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Doctrine\Tests\ORM\Functional\Ticket; | |
require_once __DIR__ . '/../../../TestInit.php'; | |
class DDC500Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
{ | |
protected function setUp() { | |
parent::setUp(); | |
$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger); | |
$this->_schemaTool->createSchema(array( | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC500ParentModel'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC500Child'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC500OtherChild'), | |
)); | |
} | |
/** | |
* @group DDC-500 | |
*/ | |
public function testIssue() | |
{ | |
$test = new DDC500Child(); | |
$test->setProperty('value'); | |
$test->setAnotherProperty('another value'); | |
$this->_em->persist($test); | |
$test2 = new DDC500OtherChild(); | |
$test2->setProperty('value'); | |
$test2->setOtherProperty('other value'); | |
$this->_em->persist($test2); | |
$this->_em->flush(); | |
$this->_em->clear(); | |
$children = $this->_em->getRepository(__NAMESPACE__ . '\DDC500Child')->findAll(); | |
} | |
} | |
/** | |
* @Entity | |
* @InheritanceType("SINGLE_TABLE") | |
* @DiscriminatorColumn(name="type", type="string") | |
* @DiscriminatorMap({"DDC500Child", "DDC500OtherChild"}) | |
*/ | |
abstract class DDC500ParentModel | |
{ | |
/** | |
* @Id @Column(name="id", type="integer") | |
* @GeneratedValue(strategy="AUTO") | |
*/ | |
protected $id; | |
/** @Column(type="string") */ | |
protected $property; | |
function getId() {return $this->id;} | |
function setProperty($property) {$this->property = $property;} | |
} | |
abstract class DDC500SubParent extends DDC500ParentModel | |
{ | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC500Child extends DDC500SubParent | |
{ | |
/** @Column(type="string", nullable="false") */ | |
protected $anotherProperty; | |
function setAnotherProperty($property) {$this->anotherProperty = $property;} | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC500OtherChild extends DDC500SubParent | |
{ | |
/** @Column(type="string", nullable="false") */ | |
protected $someOtherProperty; | |
function setOtherProperty($property) {$this->otherProperty = $property;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment