private function loadCompanyOrganizationEventJoinedSubclassFixtureData() { $organization = new CompanyOrganization(); $event1 = new CompanyAuction(); $event1->setData('foo'); $event2 = new CompanyAuction(); $event2->setData('bar'); $organization->addEvent($event1); $organization->addEvent($event2); $this->_em->persist($organization); $this->_em->flush(); $this->_em->clear(); $this->organizationId = $organization->getId(); $this->eventId1 = $event1->getId(); $this->eventId2 = $event2->getId(); }
public function testLazyLoading1() { $org = new CompanyOrganization(); $event1 = new CompanyAuction(); $event1->setData('auction'); $org->addEvent($event1); $event2 = new CompanyRaffle(); $event2->setData('raffle'); $org->addEvent($event2); $this->_em->persist($org); $this->_em->flush(); $this->_em->clear(); $orgId = $org->getId(); $q = $this->_em->createQuery('select a from Doctrine\\Tests\\Models\\Company\\CompanyOrganization a where a.id = ?1'); $q->setParameter(1, $orgId); $result = $q->getResult(); $this->assertEquals(1, count($result)); $this->assertTrue($result[0] instanceof CompanyOrganization); $this->assertNull($result[0]->getMainEvent()); $events = $result[0]->getEvents(); $this->assertTrue($events instanceof \Doctrine\ORM\PersistentCollection); $this->assertFalse($events->isInitialized()); $this->assertEquals(2, count($events)); if ($events[0] instanceof CompanyAuction) { $this->assertTrue($events[1] instanceof CompanyRaffle); } else { $this->assertTrue($events[0] instanceof CompanyRaffle); $this->assertTrue($events[1] instanceof CompanyAuction); } }