public function testFindWithProviderAndIdReturnsOneResultWhenFound()
 {
     $repo = self::$DI['app']['orm.em']->getRepository('Phraseanet:UsrAuthProvider');
     $auth = new UsrAuthProvider();
     $auth->setUser(self::$DI['user']);
     $auth->setProvider('provider-test');
     $auth->setDistantId(12345);
     self::$DI['app']['orm.em']->persist($auth);
     self::$DI['app']['orm.em']->flush();
     $this->assertSame($auth, $repo->findWithProviderAndId('provider-test', 12345));
 }
Пример #2
0
 public function testDeleteSetMailToNullAndRemovesProviders()
 {
     $user = self::$DI['app']['manipulator.user']->createUser('test_phpunit_providers', 'any');
     $provider = new UsrAuthProvider();
     $provider->setDistantId(12345);
     $provider->setProvider('custom-one');
     $provider->setUser($user);
     self::$DI['app']['orm.em']->persist($provider);
     self::$DI['app']['orm.em']->flush();
     self::$DI['app']['manipulator.user']->delete($user);
     $this->assertNull(self::$DI['app']['orm.em']->getRepository('Phraseanet:UsrAuthProvider')->findWithProviderAndId('custom-one', 12345));
 }
Пример #3
0
 private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, User $user)
 {
     $usrAuthProvider = new UsrAuthProvider();
     $usrAuthProvider->setDistantId($provider->getToken()->getId());
     $usrAuthProvider->setProvider($provider->getId());
     $usrAuthProvider->setUser($user);
     try {
         $provider->logout();
     } catch (RuntimeException $e) {
         // log these errors
     }
     $em->persist($usrAuthProvider);
 }
 /**
  * {@inheritDoc}
  */
 public function setProvider($provider)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setProvider', array($provider));
     return parent::setProvider($provider);
 }