-
-
Save doctrinebot/1f3ea54f624b9fac5e82 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-512 - https://github.com/doctrine/doctrine2/issues/5020
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 DDC512Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
{ | |
protected function setUp() | |
{ | |
parent::setUp(); | |
$this->_schemaTool->createSchema(array( | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Customer'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512OfferItem'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC512Item'), | |
)); | |
} | |
public function testIssue() | |
{ | |
$customer = new DDC512Customer(); | |
$item = new DDC512OfferItem(); | |
$customer->item = $item; | |
$this->_em->persist($customer); | |
$customer = new DDC512Customer(); | |
$this->_em->persist($customer); | |
$this->_em->flush(); | |
$q = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC512Customer u left join u.item i"); | |
$q2 = $this->_em->createQuery("select u from ".__NAMESPACE__."\\DDC512Customer u"); | |
$this->assertEquals(count($q->getResult()), count($q2->getResult())); | |
} | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC512Customer { | |
/** | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue(strategy="AUTO") | |
*/ | |
public $id; | |
/** | |
* @OneToOne(targetEntity="DDC512OfferItem", cascade={"remove","persist"}) | |
* @JoinColumn(name="item", referencedColumnName="id") | |
*/ | |
public $item; | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC512OfferItem extends DDC512Item | |
{ | |
} | |
/** | |
* @Entity | |
* @InheritanceType("JOINED") | |
* @DiscriminatorColumn(name="discr", type="string") | |
* @DiscriminatorMap({"item" = "DDC512Item", "offerItem" = "DDC512OfferItem"}) | |
*/ | |
class DDC512Item | |
{ | |
/** | |
* @Id | |
* @Column(type="integer") | |
* @GeneratedValue(strategy="AUTO") | |
*/ | |
public $id; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment