public function testShowQuestion()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $survey->save();
     $question->survey()->associate($survey)->save();
     $response = $this->call('GET', route('question.show', ['id' => $question->id]));
     $savingUrl = route('question.question_response.store', ['question_id' => $question->id], false);
     $absoluteSavingUrl = route('question.question_response.store', ['question_id' => $question->id]);
     $this->assertContains($question->body, $response->getContent());
     $this->assertContains($savingUrl . '?Kind=voice', $response->getContent());
     $this->assertNotContains($absoluteSavingUrl, $response->getContent());
 }
 public function testStoreResponse()
 {
     $survey = new Survey(['title' => 'Testing survey']);
     $questionOne = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $questionTwo = new Question(['body' => 'What is that?', 'kind' => 'voice']);
     $survey->save();
     $questionOne->survey()->associate($survey)->save();
     $questionTwo->survey()->associate($survey)->save();
     $responseForQuestion = ['RecordingUrl' => '//somefake.mp3', 'CallSid' => '7h1515un1qu3', 'Kind' => 'voice'];
     $firstResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionOne->id]), $responseForQuestion);
     $routeToNextQuestion = route('question.show', ['id' => $questionTwo->id], false);
     $routeToNextQuestionAbsolute = route('question.show', ['id' => $questionTwo->id], true);
     $this->assertContains($routeToNextQuestion, $firstResponse->getContent());
     $secondResponse = $this->call('POST', route('question.question_response.store', ['question_id' => $questionTwo->id]), $responseForQuestion);
     $this->assertNotContains('Redirect', $secondResponse->getContent());
 }
 /**
  * GET test question response index
  *
  * @return void
  */
 public function testQuestionSurveyResults()
 {
     $responseDataOne = ['kind' => 'voice', 'response' => '//faketyfake.mp3', 'call_sid' => '4l505up3run1qu3'];
     $responseDataTwo = ['kind' => 'voice', 'response' => '//somefakesound.mp3', 'call_sid' => '5up3run1qu3'];
     $question = new Question(['body' => 'What is this?', 'kind' => 'voice']);
     $question->survey()->associate($this->firstSurvey);
     $question->save();
     $question->responses()->createMany([$responseDataOne, $responseDataTwo]);
     $question->push();
     $response = $this->call('GET', route('survey.results', ['id' => $this->firstSurvey->id]));
     $this->assertEquals($response->original['responses']->count(), 2);
     $actualResponseOne = $response->original['responses']->get(0)->toArray()[0];
     $actualResponseTwo = $response->original['responses']->get(1)->toArray()[0];
     $this->assertArraySubset($responseDataOne, $actualResponseOne);
     $this->assertArraySubset($responseDataTwo, $actualResponseTwo);
 }