3 namespace Doctrine\Tests\ORM\Functional\Ticket;
7 require_once __DIR__ . '/../../../TestInit.php';
9 class DDC633Test extends \Doctrine\Tests\OrmFunctionalTestCase
11 protected function setUp()
15 $this->_schemaTool->createSchema(array(
16 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Patient'),
17 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC633Appointment'),
19 } catch(\Exception $e) {
29 public function testOneToOneEager()
31 $app = new DDC633Appointment();
32 $pat = new DDC633Patient();
34 $pat->appointment = $app;
36 $this->_em->persist($app);
37 $this->_em->persist($pat);
41 $eagerAppointment = $this->_em->find(__NAMESPACE__ . '\DDC633Appointment', $app->id);
43 // Eager loading of one to one leads to fetch-join
44 $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
45 $this->assertTrue($this->_em->contains($eagerAppointment->patient));
52 public function testDQLDeferredEagerLoad()
54 for ($i = 0; $i < 10; $i++) {
55 $app = new DDC633Appointment();
56 $pat = new DDC633Patient();
58 $pat->appointment = $app;
60 $this->_em->persist($app);
61 $this->_em->persist($pat);
66 $appointments = $this->_em->createQuery("SELECT a FROM " . __NAMESPACE__ . "\DDC633Appointment a")->getResult();
68 foreach ($appointments AS $eagerAppointment) {
69 $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $eagerAppointment->patient);
70 $this->assertTrue($eagerAppointment->patient->__isInitialized__, "Proxy should already be initialized due to eager loading!");
78 class DDC633Appointment
80 /** @Id @Column(type="integer") @GeneratedValue */
84 * @OneToOne(targetEntity="DDC633Patient", inversedBy="appointment", fetch="EAGER")
95 /** @Id @Column(type="integer") @GeneratedValue */
99 * @OneToOne(targetEntity="DDC633Appointment", mappedBy="patient")