コード例 #1
0
ファイル: NetizenFactory.php プロジェクト: xtrasmal/iinano
 /**
  * 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;
 }
コード例 #2
0
 public function getValidInputs()
 {
     $promoted = new Netizen(new Author('kirk'));
     $promoted->setGroup('ROLE_ADMIN');
     return [[['group' => 'ROLE_ADMIN'], $promoted]];
 }
コード例 #3
0
ファイル: NetizenTest.php プロジェクト: xtrasmal/iinano
 public function getComparableUser()
 {
     $user = new Netizen(new \Trismegiste\Socialist\Author('kirk'));
     $user->setGroup('USER');
     $user2 = clone $user;
     $user->setGroup('ADMIN');
     $user3 = clone $user;
     return [[$user, $user, true], [$user, $user2, false], [$user, $user3, true]];
 }
コード例 #4
0
 /**
  * @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException
  * @expectedExceptionMessage You can't promote yourself
  */
 public function testNoPromoteNetizenOnHimself()
 {
     $user = new Netizen(new Author('spock'));
     $secu = $this->createSecurityContextMockFromUser(clone $user);
     $user->setGroup('ROLE_MANAGER');
     $this->sut->promote($user, $secu);
 }