當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Question::survey方法代碼示例

本文整理匯總了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());
 }
開發者ID:illuminate3,項目名稱:automated-survey-laravel,代碼行數:13,代碼來源:QuestionControllerTest.php

示例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());
 }
開發者ID:illuminate3,項目名稱:automated-survey-laravel,代碼行數:16,代碼來源:QuestionResponseControllerTest.php

示例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);
 }
開發者ID:illuminate3,項目名稱:automated-survey-laravel,代碼行數:21,代碼來源:SurveyControllerTest.php


注:本文中的app\Question::survey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。