コード例 #1
0
 public function testLazyLoadedWithNotifyPropertyChanged()
 {
     $user = new User();
     $profile = new ProfileNotify();
     $profile->setFirstName('Maciej');
     $user->setProfileNotify($profile);
     $user->setUsername('malarzm');
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->find(get_class($user), $user->getId());
     $this->assertTrue($user->getProfileNotify() instanceof \Doctrine\Common\Persistence\Proxy);
     $this->assertFalse($user->getProfileNotify()->__isInitialized());
     $user->getProfileNotify()->setLastName('Malarz');
     $this->dm->flush();
     $this->dm->clear();
     $profile = $this->dm->find(get_class($profile), $profile->getProfileId());
     $this->assertEquals('Maciej', $profile->getFirstName());
     $this->assertEquals('Malarz', $profile->getLastName());
 }
コード例 #2
0
 public function testModifyingCollectionInChangeTrackingNotifyDocument()
 {
     $profile = new ProfileNotify();
     $f1 = new File();
     $f1->setName('av.jpeg');
     $profile->getImages()->add($f1);
     $f2 = new File();
     $f2->setName('ghost.gif');
     $profile->getImages()->add($f2);
     $this->dm->persist($profile);
     $this->dm->flush();
     $profile = $this->dm->find(get_class($profile), $profile->getProfileId());
     $profile->getImages()->move(0, 1);
     $this->dm->flush();
     $this->dm->clear();
     $profile = $this->dm->find(get_class($profile), $profile->getProfileId());
     $this->assertCount(2, $profile->getImages());
     $this->assertEquals($f2->getName(), $profile->getImages()[0]->getName());
     $this->assertEquals($f1->getName(), $profile->getImages()[1]->getName());
 }