Ejemplo n.º 1
0
 /**
  * Create and return array of ClientQuestionnaireAnswer objects by $answers array
  *
  * @param array $answers
  * @return array
  */
 private function createUserAnswers(array $answers)
 {
     $userAnswers = array();
     foreach ($answers as $answer) {
         /** @var RiskQuestion $question */
         $question = $answer['question'];
         $data = $answer['data'];
         if ($question->getIsWithdrawAgeInput()) {
             $data = $this->getAnswerForWithdrawAgeQuestion($question, $answer['data']);
         }
         $userAnswer = new ClientQuestionnaireAnswer();
         $userAnswer->setClient($this->user);
         $userAnswer->setQuestion($question);
         $userAnswer->setAnswer($data);
         $userAnswers[] = $userAnswer;
     }
     return $userAnswers;
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     $questions = array();
     for ($i = 0; $i < 4; $i++) {
         $question = new RiskQuestion();
         $question->setTitle('Question ' . ($i + 1));
         for ($j = 0; $j < 4; $j++) {
             $answer = new RiskAnswer();
             $answer->setTitle('Answer ' . ($i + 1) . ' - ' . ($j + 1));
             $answer->setQuestion($question);
             $answer->setPoint($j);
             $question->addAnswer($answer);
         }
         $questions[] = $question;
     }
     $userAnswers = array();
     foreach ($questions as $key => $question) {
         $userAnswer = new ClientQuestionnaireAnswer();
         $userAnswer->setQuestion($question);
         $questionAnswers = $question->getAnswers();
         $userAnswer->setAnswer($questionAnswers[$key]);
         $userAnswers[] = $userAnswer;
     }
     $portfolio = new CeModel();
     for ($i = 0; $i < 4; $i++) {
         $modelMock = $this->getMock('Wealthbot\\AdminBundle\\Entity\\CeModel', array('getId'));
         $modelMock->expects($this->any())->method('getId')->will($this->returnValue($i + 1));
         $modelMock->setName('Model ' . ($i + 1));
         $modelMock->setRiskRating($i + 1);
         $portfolio->addChildren($modelMock);
     }
     $riaCompanyInformation = new RiaCompanyInformation();
     $riaCompanyInformation->setPortfolioModel($portfolio);
     $ria = new User();
     $ria->setRoles(array('ROLE_RIA'));
     $ria->setRiaCompanyInformation($riaCompanyInformation);
     $userProfile = new Profile();
     $userProfile->setRia($ria);
     $user = new User();
     $user->setRoles(array('ROLE_CLIENT'));
     $user->setProfile($userProfile);
     $this->riskTolerance = new RiskTolerance($user, $userAnswers);
 }
Ejemplo n.º 3
0
 private function createClientQuestionnaireAnswer(array $data, User $clientUser)
 {
     $clientAnswer = new ClientQuestionnaireAnswer();
     $clientAnswer->setClient($clientUser);
     $clientAnswer->setQuestion($this->getReference('cec-question-' . $data['q_index']));
     $clientAnswer->setAnswer($this->getReference('cec-answer-' . $data['q_index'] . '-' . $data['a_index']));
     return $clientAnswer;
 }