/** * @test */ public function initialize() { $this->collection->drop(); $authorList = []; foreach (['kirk', 'spock', 'mccoy'] as $nick) { $authorList[] = new Author($nick); } $target = $authorList[0]; foreach ($authorList as $author) { $user = new Netizen($author); $user->setProfile(new Profile()); $this->repository->persist($user); if ($target === $author) { $targetUser = $user; } } $source = new SmallTalk($target); $commentary = new Commentary($target); $source->attachCommentary($commentary); foreach ($authorList as $other) { if ($other === $target) { continue; } $source->addFan($other); $commentary->addFan($other); } $this->repository->batchPersist([$source, $source, $source]); $this->assertCount(6, $this->collection->find()); return (string) $targetUser->getId(); }
public function testPersist() { $this->storage->expects($this->once())->method('updateAvatar'); $this->repository->expects($this->exactly(2))->method('persist'); $user = new Netizen(new Author('kirk')); $user->setProfile(new Profile()); $this->sut->persist($user); return $user; }
/** * Creates a new Netizen from mandatory datas * * @param string $nick * @param string $OauthProviderKey the key of the OAuth provider (github,facebook,twitter...) * @param string $uniqueUserId the unique id of the user given by the OAuth provider * * @return \Trismegiste\SocialBundle\Security\Netizen */ public function create($nick, $OauthProviderKey, $uniqueUserId) { $author = new Author($nick); $user = new Netizen($author); $strat = new Credential\OAuth($uniqueUserId, $OauthProviderKey); $user->setCredential($strat); $user->setProfile(new Profile()); $user->setGroup('ROLE_USER'); return $user; }
/** * @test */ public function initialize() { $this->collection->drop(); $author = new Author('kirk'); $user = new Netizen($author); $user->setProfile(new \Trismegiste\SocialBundle\Security\Profile()); $this->repository->persist($user); $source = new SmallTalk($author); $this->repository->batchPersist([$source, $source, $source]); $this->assertCount(4, $this->collection->find()); return (string) $user->getId(); }
public function testProfile() { $profile = $this->getMock('Trismegiste\\SocialBundle\\Security\\Profile'); $this->sut->setProfile($profile); $this->assertEquals($profile, $this->sut->getProfile()); }