-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathValidateAnswerSingleSelectTest.php
More file actions
72 lines (68 loc) · 2.2 KB
/
ValidateAnswerSingleSelectTest.php
File metadata and controls
72 lines (68 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* QuestionnaireAnswer::validate()のテスト
*
* @property QuestionnaireAnswer $QuestionnaireAnswer
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Allcreator <info@allcreator.net>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2014, NetCommons Project
*/
App::uses('QuestionnaireAnswerValidateTest', 'Questionnaires.TestSuite');
App::uses('QuestionnairesComponent', 'Questionnaires.Controller/Component');
/**
* QuestionnaireAnswer::validate()のテスト
*
* @author Allcreator <info@allcreator.net>
* @package NetCommons\Questionnaires\Test\Case\Model\QuestionnaireAnswer
*/
class ValidateAnswerSingleSelectTest extends QuestionnaireAnswerValidateTest {
/**
* __getData
*
* @param string $qKey 質問キー
* @param int $summaryId サマリID
* @return array
*/
private function __getData($qKey, $summaryId) {
$answerData = array(
array(
'questionnaire_answer_summary_id' => $summaryId,
'answer_value' => '|choice_2:choice label1',
'questionnaire_question_key' => $qKey,
'id' => '',
'matrix_choice_key' => '',
'other_answer_value' => ''
)
);
return $answerData;
}
/**
* testValidationErrorのDataProvider
*
* #### 戻り値
* - array 取得するキー情報
* - array 期待値 (取得したキー情報)
*
* @return array
*/
public function dataProviderValidationError() {
$data = $this->__getData('qKey_1', 3);
// 通常の質問
$normalQuestion = $this->_getQuestion(2);
// 解答必須質問
$requireQuestion = Hash::merge($normalQuestion, array('is_require' => QuestionnairesComponent::REQUIRES_REQUIRE));
// その他回答がある質問
$otherQuestion = Hash::merge($normalQuestion, array('QuestionnaireChoice' => array(array('other_choice_type' => 1))));
return array(
array($data, 3, $normalQuestion, 'answer_value', 'aaa',
__d('questionnaires', 'Invalid choice')),
array($data, 3, $requireQuestion, 'answer_value', '',
__d('questionnaires', 'Input required')),
array($data, 3, $otherQuestion, 'other_answer_value', '',
__d('questionnaires', 'Please enter something, if you chose the other item')),
);
}
}