Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1300Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 require_once __DIR__ . '/../../../TestInit.php';
6
7 /**
8  * @group DDC-1300
9  */
10 class DDC1300Test extends \Doctrine\Tests\OrmFunctionalTestCase
11 {
12     public function setUp()
13     {
14         parent::setUp();
15         $this->_schemaTool->createSchema(array(
16             $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300Foo'),
17             $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1300FooLocale'),
18         ));
19     }
20
21     public function testIssue()
22     {
23         $foo = new DDC1300Foo();
24         $foo->_fooReference = "foo";
25
26         $this->_em->persist($foo);
27         $this->_em->flush();
28
29         $locale = new DDC1300FooLocale();
30         $locale->_foo = $foo;
31         $locale->_locale = "en";
32         $locale->_title = "blub";
33
34         $this->_em->persist($locale);
35         $this->_em->flush();
36
37         $query = $this->_em->createQuery('SELECT f, fl FROM Doctrine\Tests\ORM\Functional\Ticket\DDC1300Foo f JOIN f._fooLocaleRefFoo fl');
38         $result =  $query->getResult();
39
40         $this->assertEquals(1, count($result));
41     }
42 }
43
44 /**
45  * @Entity
46  */
47 class DDC1300Foo
48 {
49     /**
50      * @var integer fooID
51      * @Column(name="fooID", type="integer", nullable=false)
52      * @GeneratedValue(strategy="AUTO")
53      * @Id
54      */
55     public $_fooID = null;
56
57     /**
58      * @var string fooReference
59      * @Column(name="fooReference", type="string", nullable=true, length=45)
60      */
61     public $_fooReference = null;
62
63     /**
64      * @OneToMany(targetEntity="DDC1300FooLocale", mappedBy="_foo",
65      * cascade={"persist"})
66      */
67     public $_fooLocaleRefFoo = null;
68
69     /**
70      * Constructor
71      *
72      * @param array|Zend_Config|null $options
73      * @return Bug_Model_Foo
74      */
75     public function __construct($options = null)
76     {
77         $this->_fooLocaleRefFoo = new \Doctrine\Common\Collections\ArrayCollection();
78     }
79
80 }
81
82 /**
83  * @Entity
84  */
85 class DDC1300FooLocale
86 {
87
88     /**
89      * @ManyToOne(targetEntity="DDC1300Foo")
90      * @JoinColumn(name="fooID", referencedColumnName="fooID")
91      * @Id
92      */
93     public $_foo = null;
94
95     /**
96      * @var string locale
97      * @Column(name="locale", type="string", nullable=false, length=5)
98      * @Id
99      */
100     public $_locale = null;
101
102     /**
103      * @var string title
104      * @Column(name="title", type="string", nullable=true, length=150)
105      */
106     public $_title = null;
107
108 }