本文整理汇总了PHP中app\Question::survey方法的典型用法代码示例。如果您正苦于以下问题:PHP Question::survey方法的具体用法?PHP Question::survey怎么用?PHP Question::survey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Question
的用法示例。
在下文中一共展示了Question::survey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShowQuestion
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());
}
示例2: testStoreResponse
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());
}
示例3: testQuestionSurveyResults
/**
* 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);
}