-
-
Save doctrinebot/6a106ee22e49bdee4fb3 to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-1504 - https://github.com/doctrine/doctrine2/issues/2134
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\Tests\OrmFunctionalTestCase; | |
/** | |
* @group DDC-1504 | |
*/ | |
class DDC1504Test extends OrmFunctionalTestCase | |
{ | |
public function setUp() | |
{ | |
parent::setUp(); | |
$this->_schemaTool->createSchema(array( | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1514Structure'), | |
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1514Employee'), | |
)); | |
} | |
public function testIssue() | |
{ | |
$structure = new DDC1514Structure(); | |
$employee1 = new DDC1514Employee(); | |
$employee1->structure = $structure; | |
$employee2 = new DDC1514Employee(); | |
$employee2->structure = $structure; | |
$this->_em->persist($structure); | |
$this->_em->persist($employee1); | |
$this->_em->persist($employee2); | |
$this->_em->flush(); | |
$this->_em->clear(); | |
$this->assertEquals(2, count($this->_em->getRepository(__NAMESPACE__.'\DDC1514Employee')->findAll())); | |
$structure = $this->_em->find(__NAMESPACE__.'\DDC1514Structure', $structure->id); | |
$this->_em->remove($structure); | |
$this->_em->flush(); | |
$this->assertEquals(0, count($this->_em->getRepository(__NAMESPACE__.'\DDC1514Employee')->findAll())); | |
} | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC1514Structure | |
{ | |
/** | |
* @Id @Column(type="integer") @GeneratedValue | |
*/ | |
public $id; | |
/** | |
* @var ArrayCollection $employees liste des employés d'une structure | |
* | |
* @OneToMany(targetEntity="DDC1514Employee", mappedBy="structure", cascade={"all"}) | |
*/ | |
public $employees; | |
} | |
/** | |
* @Entity | |
*/ | |
class DDC1514Employee | |
{ | |
/** | |
* @Id @Column(type="integer") @GeneratedValue | |
*/ | |
public $id;// Id and other variables | |
/** | |
* @var integer $structure | |
* | |
* @ManyToOne(targetEntity="DDC1514Structure",inversedBy="employees") | |
* @JoinColumn(name="structure_id", referencedColumnName="id",nullable=false) | |
*/ | |
public $structure; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment