当前位置: 首页>>代码示例>>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;未经允许,请勿转载。