Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1193Test.php
1 <?php
2 namespace Doctrine\Tests\ORM\Functional\Ticket;
3
4 require_once __DIR__ . '/../../../TestInit.php';
5
6 use DateTime, Doctrine\DBAL\Types\Type;
7
8 class DDC1193Test extends \Doctrine\Tests\OrmFunctionalTestCase
9 {
10     protected function setUp()
11     {
12         parent::setUp();
13         //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
14         $this->_schemaTool->createSchema(array(
15             $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Company'),
16             $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Person'),
17             $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1193Account')
18         ));
19     }
20
21     /**
22      * @group DDC-1193
23      */
24     public function testIssue()
25     {
26         $company = new DDC1193Company();
27         $person = new DDC1193Person();
28         $account = new DDC1193Account();
29
30         $person->account = $account;
31         $person->company = $company;
32
33         $company->member = $person;
34
35         $this->_em->persist($company);
36
37         $this->_em->flush();
38
39         $companyId = $company->id;
40         $accountId = $account->id;
41         $this->_em->clear();
42
43         $company = $this->_em->find(get_class($company), $companyId);
44
45         $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company), "Company is in identity map.");
46         $this->assertFalse($company->member->__isInitialized__, "Pre-Condition");
47         $this->assertTrue($this->_em->getUnitOfWork()->isInIdentityMap($company->member), "Member is in identity map.");
48
49         $this->_em->remove($company);
50         $this->_em->flush();
51
52         $this->assertEquals(count($this->_em->getRepository(get_class($account))->findAll()), 0);
53     }
54 }
55
56 /** @Entity */
57 class DDC1193Company {
58     /**
59      * @Id @Column(type="integer")
60      * @GeneratedValue
61      */
62     public $id;
63
64     /** @OneToOne(targetEntity="DDC1193Person", cascade={"persist", "remove"}) */
65     public $member;
66
67 }
68
69 /** @Entity */
70 class DDC1193Person {
71     /**
72      * @Id @Column(type="integer")
73      * @GeneratedValue
74      */
75     public $id;
76
77     /**
78      * @OneToOne(targetEntity="DDC1193Account", cascade={"persist", "remove"})
79      */
80     public $account;
81 }
82
83 /** @Entity */
84 class DDC1193Account {
85     /**
86      * @Id @Column(type="integer")
87      * @GeneratedValue
88      */
89     public $id;
90
91 }
92
93