3 namespace Doctrine\Tests\ORM\Functional\Ticket;
5 require_once __DIR__ . '/../../../TestInit.php';
10 class DDC1080Test extends \Doctrine\Tests\OrmFunctionalTestCase
12 public function testHydration()
14 $this->_schemaTool->createSchema(array(
15 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Foo'),
16 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080Bar'),
17 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1080FooBar'),
20 $foo1 = new DDC1080Foo();
21 $foo1->setFooTitle('foo title 1');
22 $foo2 = new DDC1080Foo();
23 $foo2->setFooTitle('foo title 2');
25 $bar1 = new DDC1080Bar();
26 $bar1->setBarTitle('bar title 1');
27 $bar2 = new DDC1080Bar();
28 $bar2->setBarTitle('bar title 2');
29 $bar3 = new DDC1080Bar();
30 $bar3->setBarTitle('bar title 3');
32 $foobar1 = new DDC1080FooBar();
33 $foobar1->setFoo($foo1);
34 $foobar1->setBar($bar1);
35 $foobar1->setOrderNr(0);
37 $foobar2 = new DDC1080FooBar();
38 $foobar2->setFoo($foo1);
39 $foobar2->setBar($bar2);
40 $foobar2->setOrderNr(0);
42 $foobar3 = new DDC1080FooBar();
43 $foobar3->setFoo($foo1);
44 $foobar3->setBar($bar3);
45 $foobar3->setOrderNr(0);
47 $this->_em->persist($foo1);
48 $this->_em->persist($foo2);
49 $this->_em->persist($bar1);
50 $this->_em->persist($bar2);
51 $this->_em->persist($bar3);
54 $this->_em->persist($foobar1);
55 $this->_em->persist($foobar2);
56 $this->_em->persist($foobar3);
60 $foo = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC1080Foo', $foo1->getFooId());
61 $fooBars = $foo->getFooBars();
63 $this->assertEquals(3, count($fooBars), "Should return three foobars.");
77 * @Column(name="fooID", type="integer")
78 * @GeneratedValue(strategy="AUTO")
82 * @Column(name="fooTitle", type="string")
86 * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_foo",
87 * cascade={"persist"})
88 * @OrderBy({"_orderNr"="ASC"})
92 public function __construct()
94 $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection();
100 public function getFooID()
102 return $this->_fooID;
106 * @return the $fooTitle
108 public function getFooTitle()
110 return $this->_fooTitle;
114 * @return the $fooBars
116 public function getFooBars()
118 return $this->_fooBars;
122 * @param field_type $fooID
124 public function setFooID($fooID)
126 $this->_fooID = $fooID;
130 * @param field_type $fooTitle
132 public function setFooTitle($fooTitle)
134 $this->_fooTitle = $fooTitle;
138 * @param field_type $fooBars
140 public function setFooBars($fooBars)
142 $this->_fooBars = $fooBars;
155 * @Column(name="barID", type="integer")
156 * @GeneratedValue(strategy="AUTO")
160 * @Column(name="barTitle", type="string")
162 protected $_barTitle;
164 * @OneToMany(targetEntity="DDC1080FooBar", mappedBy="_bar",
165 * cascade={"persist"})
166 * @OrderBy({"_orderNr"="ASC"})
170 public function __construct()
172 $this->_fooBars = new \Doctrine\Common\Collections\ArrayCollection();
178 public function getBarID()
180 return $this->_barID;
184 * @return the $barTitle
186 public function getBarTitle()
188 return $this->_barTitle;
192 * @return the $fooBars
194 public function getFooBars()
196 return $this->_fooBars;
200 * @param field_type $barID
202 public function setBarID($barID)
204 $this->_barID = $barID;
208 * @param field_type $barTitle
210 public function setBarTitle($barTitle)
212 $this->_barTitle = $barTitle;
216 * @param field_type $fooBars
218 public function setFooBars($fooBars)
220 $this->_fooBars = $fooBars;
226 * @Table(name="fooBar")
233 * @ManyToOne(targetEntity="DDC1080Foo")
234 * @JoinColumn(name="fooID", referencedColumnName="fooID")
237 protected $_foo = null;
239 * @ManyToOne(targetEntity="DDC1080Bar")
240 * @JoinColumn(name="barID", referencedColumnName="barID")
243 protected $_bar = null;
245 * @var integer orderNr
246 * @Column(name="orderNr", type="integer", nullable=false)
248 protected $_orderNr = null;
251 * Retrieve the foo property
255 public function getFoo()
261 * Set the foo property
263 * @param DDC1080Foo $foo
264 * @return DDC1080FooBar
266 public function setFoo($foo)
273 * Retrieve the bar property
277 public function getBar()
283 * Set the bar property
285 * @param DDC1080Bar $bar
286 * @return DDC1080FooBar
288 public function setBar($bar)
295 * Retrieve the orderNr property
297 * @return integer|null
299 public function getOrderNr()
301 return $this->_orderNr;
305 * Set the orderNr property
307 * @param integer|null $orderNr
308 * @return DDC1080FooBar
310 public function setOrderNr($orderNr)
312 $this->_orderNr = $orderNr;