public function testModelReturnType() { $model = new SyncModel(); $this->assertTrue(is_string($model->tableName())); $this->assertTrue(is_array($model->scenarios())); $this->assertTrue(is_array($model->rules())); $this->assertTrue(is_array($model->attributeLabels())); }
/** * @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; }