Пример #1
0
 public function testFakeSyncOpenIDWrongConnection()
 {
     $fakeSyncService = new SyncService(['serviceClass' => '\\yii\\authclient\\OpenId', 'returnUrl' => 'http://my_own_site/returnUrl']);
     $this->setExpectedException('yii\\base\\Exception', Yii::t('SyncSocial', 'SyncSocial is not support {serviceName}.', ['serviceName' => 'yii\\authclient\\OpenId']));
     $fakeSyncService->connect();
     $this->assertTrue(true);
 }
Пример #2
0
 /**
  * @param SyncService $service
  * @param ActiveRecord $model
  * @param array $data
  *
  * @return bool
  * @throws Exception
  */
 protected function createSyncModel(SyncService $service, ActiveRecord $model, array $data = array())
 {
     $syncModel = new SyncModel();
     $syncModel->attributes = ['model_id' => $model->getPrimaryKey(), 'service_name' => $service->getName(), 'service_id_author' => $data['service_id_author'], 'service_id_post' => $data['service_id_post'], 'time_created' => !empty($data['time_created']) ? $data['time_created'] : time()];
     $flag = $syncModel->save();
     if ($syncModel->hasErrors()) {
         throw new InvalidConfigException(Yii::t('SyncSocial', 'Wrong sync model configuration for SyncSocial extension'));
     }
     return $flag;
 }
Пример #3
0
 public function testReturnNullDefault()
 {
     $sync = new SyncService(['serviceClass' => '\\tests\\models\\TestOAuth2', 'returnUrl' => 'http://fakehost/returnUrl']);
     $this->assertTrue(is_null($sync->getPosts()));
     $this->assertTrue(is_null($sync->publishPost('message')));
     $this->assertTrue($sync->deletePost(1) === false);
     $this->assertTrue(!$sync->isReadOnly());
 }