-
-
Save doctrinebot/df568064cdd66430903d to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-567 - https://github.com/doctrine/doctrine2/issues/5073
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 DDC567Test 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__ . '\DDC567Class1'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC567Class2') | |
)); | |
} | |
/** | |
* @group DDC-567 | |
*/ | |
public function testIssue() | |
{ | |
$class1 = new DDC567Class1(); | |
$this->_em->persist($class1); | |
$class2 = new DDC567Class2(); | |
$class2->setSysname('class2'); | |
$this->_em->persist($class2); | |
$this->_em->flush(); | |
$class1->setRef($class2); | |
$this->_em->flush(); | |
} | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC567Class1 | |
{ | |
/** | |
* @Id @Column(name="id", type="integer") | |
* @GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* @ManyToOne(targetEntity="Doctrine\Tests\ORM\Functional\Ticket\DDC567Class2") | |
* @JoinColumn(name="ref_sysname", referencedColumnName="sysname", nullable="TRUE") | |
*/ | |
protected $ref; | |
public function setRef($ref) { $this->ref = $ref; } | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC567Class2 | |
{ | |
/** | |
* @Id @Column(name="id", type="integer") | |
* @GeneratedValue | |
*/ | |
protected $id; | |
/** | |
* @Column(type="string", name="sysname", length=40, unique="TRUE") | |
*/ | |
protected $sysname; | |
public function setSysname($sysname) { $this->sysname = $sysname; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment