Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:47
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/df568064cdd66430903d to your computer and use it in GitHub Desktop.
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
<?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