public function testStoreLastQuestionSmsAnswer() { $this->assertCount(0, QuestionResponse::all()); $firstResponse = $this->call('POST', route('response.store.sms', ['question' => $this->questionTwo->id, 'survey' => $this->survey->id]), ['Body' => 'Some answer two'], ['survey_session' => 'session_SID']); $cookies = $firstResponse->headers->getCookies(); $messageDocument = new SimpleXMLElement($firstResponse->getContent()); $this->assertCount(1, QuestionResponse::all()); $questionResponse = QuestionResponse::first(); $this->assertCount(2, $cookies); $this->assertEquals('Some answer two', $questionResponse->response); $this->assertEquals('session_SID', $questionResponse->session_sid); $this->assertEquals('sms', $questionResponse->type); $this->assertEquals($this->questionTwo->id, $questionResponse->question_id); $this->assertEquals("That was the last question.\n" . "Thank you for participating in this survey.\n" . 'Good bye.', strval($messageDocument->Message)); }
public function showResults($surveyId) { $survey = \App\Survey::find($surveyId); $responsesByCall = \App\QuestionResponse::responsesForSurveyByCall($surveyId)->get()->groupBy('call_sid')->values(); return response()->view('surveys.results', ['survey' => $survey, 'responses' => $responsesByCall]); }