2011-06-05 09:59:16 +02:00
|
|
|
<?php
|
2016-05-11 01:55:12 +07:00
|
|
|
|
2011-06-05 09:59:16 +02:00
|
|
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
|
|
|
|
2016-05-11 01:55:12 +07:00
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
2011-06-05 09:59:16 +02:00
|
|
|
|
2016-05-11 01:55:12 +07:00
|
|
|
class DDC1193Test extends OrmFunctionalTestCase
|
2011-06-05 09:59:16 +02:00
|
|
|
{
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
//$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
|
2016-12-07 23:33:41 +01:00
|
|
|
$this->_schemaTool->createSchema(
|
|
|
|
[
|
2016-12-08 18:01:04 +01:00
|
|
|
$this->_em->getClassMetadata(DDC1193Company::class),
|
|
|
|
$this->_em->getClassMetadata(DDC1193Person::class),
|
|
|
|
$this->_em->getClassMetadata(DDC1193Account::class)
|
2016-12-07 23:33:41 +01:00
|
|
|
]
|
|
|
|
);
|
2011-06-05 09:59:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-1193
|
|
|
|
*/
|
|
|
|
public function testIssue()
|
|
|
|
{
|
|
|
|
$company = new DDC1193Company();
|
|
|
|
$person = new DDC1193Person();
|
|
|
|
$account = new DDC1193Account();
|
|
|
|
|
|
|
|
$person->account = $account;
|
|
|
|
$person->company = $company;
|
|
|
|
|
|
|
|
$company->member = $person;
|
|
|
|
|
|
|
|
$this->_em->persist($company);
|
|
|
|
|
|
|
|
$this->_em->flush();
|
|
|
|
|
|
|
|
$companyId = $company->id;
|
|
|
|
$accountId = $account->id;
|
|
|
|
$this->_em->clear();
|
|
|
|
|
|
|
|
$company = $this->_em->find(get_class($company), $companyId);
|
|
|
|
|
|
|
|
$this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), "Company is in identity map.");
|
|
|
|
$this->assertFalse($company->member->__isInitialized__, "Pre-Condition");
|
|
|
|
$this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), "Member is in identity map.");
|
2011-12-19 22:56:19 +01:00
|
|
|
|
2011-06-05 09:59:16 +02:00
|
|
|
$this->_em->remove($company);
|
|
|
|
$this->_em->flush();
|
|
|
|
|
|
|
|
$this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @Entity */
|
|
|
|
class DDC1193Company {
|
|
|
|
/**
|
|
|
|
* @Id @Column(type="integer")
|
|
|
|
* @GeneratedValue
|
|
|
|
*/
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
/** @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */
|
|
|
|
public $member;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @Entity */
|
|
|
|
class DDC1193Person {
|
|
|
|
/**
|
|
|
|
* @Id @Column(type="integer")
|
|
|
|
* @GeneratedValue
|
|
|
|
*/
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"})
|
|
|
|
*/
|
|
|
|
public $account;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @Entity */
|
|
|
|
class DDC1193Account {
|
|
|
|
/**
|
|
|
|
* @Id @Column(type="integer")
|
|
|
|
* @GeneratedValue
|
|
|
|
*/
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
}
|