Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doctrinebot/486fc12da318be5d18ba to your computer and use it in GitHub Desktop.
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
<?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