Exemplo n.º 1
0
 public function testUserProfile()
 {
     $user = $this->buildUser();
     $github = new GithubProfile();
     $github->setName('Felipe Pimenta');
     $github->setLogin('felipe');
     $github->setEmail('*****@*****.**');
     $github->setAvatar('felipe.png');
     $facebook = new FacebookProfile();
     $facebook->setName('Felipe Pimenta');
     $facebook->setLogin('felipe');
     $facebook->setEmail('*****@*****.**');
     $facebook->setAvatar('felipe.png');
     $twitter = new TwitterProfile();
     $twitter->setName('Felipe Pimenta');
     $twitter->setLogin('felipe');
     $twitter->setEmail('*****@*****.**');
     $twitter->setAvatar('felipe.png');
     $profileCollection = new ArrayCollection();
     $profileCollection->add($github);
     $profileCollection->add($facebook);
     $profileCollection->add($twitter);
     $user->setProfileCollection($profileCollection);
     $this->getEntityManager()->persist($user);
     $this->getEntityManager()->flush();
     $savedUser = $this->getEntityManager()->find(get_class($user), 1);
     $this->assertEquals(3, count($savedUser->getProfileCollection()));
     $savedProfiles = $savedUser->getProfileCollection();
     $this->assertInstanceOf(get_class($github), $savedProfiles[0]);
     $this->assertInstanceOf(get_class($facebook), $savedProfiles[1]);
     $this->assertInstanceOf(get_class($twitter), $savedProfiles[2]);
 }