|
|
|
|
@ -65,29 +65,22 @@ class SurveyWorkflowTest extends TestCase
|
|
|
|
|
return $response->json('id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testIncompleteProfilesCannotSubmitUntilRegistrationIsComplete(): void
|
|
|
|
|
public function testSurveyAccessRequiresOnlyMobileEvenWhenOtherProfileFieldsAreMissing(): void
|
|
|
|
|
{
|
|
|
|
|
$id = $this->createQuestion();
|
|
|
|
|
$complete = clone Auth::guard('mobile')->user();
|
|
|
|
|
$pending = new User();
|
|
|
|
|
$pending->forceFill(['id' => 200, 'mobile' => '13800000000']);
|
|
|
|
|
Auth::guard('mobile')->setUser($pending);
|
|
|
|
|
$detail = '/api/mobile/course/evaluation-detail?course_content_evaluation_id=10';
|
|
|
|
|
$payload = ['course_content_evaluation_id' => 10, 'answer_version' => 2, 'data' => [['id' => $id, 'value' => ['count' => 0, 'follow' => 'yes']]]];
|
|
|
|
|
$this->getJson($detail)->assertJsonPath('requires_profile', true);
|
|
|
|
|
$this->postJson('/api/mobile/course/course-content-form', $payload)->assertJsonPath('errmsg', '请先完成绑定或注册资料');
|
|
|
|
|
$this->assertSame(0, \App\Models\CourseContentEvaluationForm::count());
|
|
|
|
|
foreach (['name', 'sex', 'birthday', 'email', 'company_name', 'company_position'] as $field) {
|
|
|
|
|
$missing = clone $complete;
|
|
|
|
|
$missing->$field = null;
|
|
|
|
|
$this->assertFalse(\App\Services\Survey\SurveyIdentity::complete($missing));
|
|
|
|
|
}
|
|
|
|
|
$monthOnly = clone $complete;
|
|
|
|
|
$monthOnly->birthday = '1990-01';
|
|
|
|
|
$this->assertFalse(\App\Services\Survey\SurveyIdentity::complete($monthOnly));
|
|
|
|
|
Auth::guard('mobile')->setUser($complete);
|
|
|
|
|
$this->getJson($detail)->assertJsonPath('requires_profile', false);
|
|
|
|
|
$this->postJson('/api/mobile/course/course-content-form', $payload)->assertJsonPath('user_id', 200);
|
|
|
|
|
$replyId = $this->postJson('/api/mobile/course/course-content-form', $payload)->assertJsonPath('user_id', 200)->json('id');
|
|
|
|
|
$pending->mobile = null;
|
|
|
|
|
$this->getJson($detail)->assertJsonPath('requires_profile', true);
|
|
|
|
|
$this->postJson('/api/mobile/course/course-content-form', $payload)->assertJsonPath('errmsg', '请先绑定或注册');
|
|
|
|
|
$pending->mobile = '13800000000';
|
|
|
|
|
$this->postJson('/api/mobile/course/course-content-form', $payload)->assertJsonPath('id', $replyId);
|
|
|
|
|
$this->assertSame(1, \App\Models\CourseContentEvaluationForm::count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRespondentFallbackIsSharedByListsDetailsAndExportWithoutUpdatingUsers(): void
|
|
|
|
|
|