コード例 #1
0
 /** @test */
 public function can_search_for_specific_question_fuzzy_match()
 {
     $interrogator = new Interrogator();
     $section = $interrogator->createSection('Section 1', [], 'MetricLoop\\Interrogator\\User', 1);
     $section2 = $interrogator->createSection('Section 2', [], 'MetricLoop\\Interrogator\\Client', 1);
     $group = $interrogator->createGroup('Group 1', $section, [], 1);
     $group2 = $interrogator->createGroup('Group 2', $section2, [], 1);
     $interrogator->createQuestion('Question 1', 1, $group, [], [], 1);
     $interrogator->createQuestion('Question 2', 2, $group, [], [], 1);
     $interrogator->createQuestion('Question 3', 3, $group, [], [], 1);
     $interrogator->createQuestion('Question 4', 4, $group, [], [], 1);
     $interrogator->createQuestion('Question 5', 5, $group, [], [], 1);
     $interrogator->createQuestion('Question 6', 6, $group, [], [], 1);
     $interrogator->createQuestion('Question 1', 1, $group2, [], [], 1);
     $interrogator->createQuestion('Question 2', 2, $group2, [], [], 1);
     $interrogator->createQuestion('Question 3', 3, $group2, [], [], 1);
     $interrogator->createQuestion('Question 4', 4, $group2, [], [], 1);
     $interrogator->createQuestion('Question 5', 5, $group2, [], [], 1);
     $interrogator->createQuestion('Question 6', 6, $group2, [], [], 1);
     $user = User::create(['name' => 'Ulysses User', 'email' => '*****@*****.**', 'current_team_id' => 1]);
     $client = Client::create(['name' => 'Carly Client', 'email' => '*****@*****.**', 'current_team_id' => 1]);
     $section = Section::where('class_name', get_class($user))->first();
     foreach ($section->groups as $group) {
         foreach ($group->questions as $question) {
             $user->answerQuestion($question, 'Test Answer');
         }
     }
     $section = Section::where('class_name', get_class($client))->first();
     foreach ($section->groups as $group) {
         foreach ($group->questions as $question) {
             $client->answerQuestion($question, 'Test Answer');
         }
     }
     $term = 'est Answe';
     $question = Question::first();
     $results = $interrogator->searchQuestion($term, get_class($user), $question, 1);
     $this->assertCount(1, $results);
 }
コード例 #2
0
 public function test_can_restore_deleted_question()
 {
     $interrogator = new Interrogator();
     $this->createTestQuestion($interrogator);
     $interrogator->deleteQuestion(1);
     $this->assertFalse(Section::first()->trashed());
     $this->assertFalse(Group::first()->trashed());
     $this->assertTrue(Question::withTrashed()->first()->trashed());
     $interrogator->restoreQuestion(1);
     $this->assertFalse(Section::first()->trashed());
     $this->assertFalse(Group::first()->trashed());
     $this->assertFalse(Question::first()->trashed());
 }