-
-
Save doctrinebot/486fc12da318be5d18ba to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-419 - https://github.com/doctrine/doctrine2/issues/4917
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; | |
use Doctrine\ORM\UnitOfWork; | |
use Doctrine\Common\Util\Debug; | |
require_once __DIR__ . '/../../../TestInit.php'; | |
class DDC381Test extends \Doctrine\Tests\OrmFunctionalTestCase | |
{ | |
protected function setUp() | |
{ | |
parent::setUp(); | |
try { | |
$this->_schemaTool->createSchema(array( | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC419Decorator'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC419Instance'), | |
)); | |
} catch(\Exception $e) { | |
} | |
} | |
public function testHydration() | |
{ | |
$i1 = new DDC419Instance(); | |
$i1->name = "foo"; | |
$this->_em->persist($i1); | |
$this->_em->flush(); | |
$d1 = new DDC419Decorator(); | |
$d1->instance = $i1; | |
$this->_em->persist($d1); | |
$this->_em->flush(); | |
$this->_em->clear(); | |
$dql = 'SELECT d, i FROM Doctrine\Tests\ORM\Functional\Ticket\DDC419Decorator d JOIN d.instance i'; | |
$data = $this->_em->createQuery($dql)->getResult(); | |
$this->assertType('Doctrine\Tests\ORM\Functional\Ticket\DDC419Instance', $data[0]->instance); | |
} | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC419Decorator | |
{ | |
/** @Column(type="integer") @Id @GeneratedValue */ | |
public $id; | |
/** | |
* @OneToOne(targetEntity="DDC419Instance") | |
* @JoinColumn(name="instance", referencedColumnName="id") | |
*/ | |
public $instance; | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC419Instance | |
{ | |
/** @Column(type="integer") @Id @GeneratedValue */ | |
public $id; | |
/** @Column */ | |
public $name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment