-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEditTest.php
More file actions
128 lines (115 loc) · 3.24 KB
/
EditTest.php
File metadata and controls
128 lines (115 loc) · 3.24 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* QuizFrameSettingsController::edit()のテスト
*
* @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('FrameSettingsControllerTest', 'Frames.TestSuite');
App::uses('QuizFixture', 'Quizzes.Test/Fixture');
App::uses('QuizzesComponent', 'Quizzes.Controller/Component');
/**
* QuizFrameSettingsController::edit()のテスト
*
* @author AllCreator <info@allcreator.net>
* @package NetCommons\Quizzes\Test\Case\Controller\QuizFrameSettingsController
*/
class QuizFrameSettingsControllerEditTest extends FrameSettingsControllerTest {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'plugin.quizzes.quiz',
'plugin.quizzes.quiz_answer',
'plugin.quizzes.quiz_answer_summary',
'plugin.quizzes.quiz_choice',
'plugin.quizzes.quiz_correct',
'plugin.quizzes.quiz_frame_display_quiz',
'plugin.quizzes.quiz_frame_setting',
'plugin.quizzes.quiz_page',
'plugin.quizzes.quiz_question',
'plugin.quizzes.block_setting_for_quiz',
'plugin.workflow.workflow_comment',
'plugin.authorization_keys.authorization_keys',
);
/**
* Plugin name
*
* @var string
*/
public $plugin = 'quizzes';
/**
* Controller name
*
* @var string
*/
protected $_controller = 'quiz_frame_settings';
/**
* テストDataの取得
*
* @return array
*/
private function __data() {
$frameId = '6';
$frameKey = 'frame_3';
$quizFrameId = '1';
$blockId = '2';
$data = array(
'Frame' => array(
'id' => $frameId,
'key' => $frameKey,
),
'Block' => array(
'id' => $blockId,
),
'QuizFrameSetting' => array(
'id' => $quizFrameId,
'frame_key' => $frameKey,
'display_type' => QuizzesComponent::DISPLAY_TYPE_LIST,
'display_num_per_page' => '10',
'sort_type' => 'Quiz.modified DESC',
),
);
$quizRec = (new QuizFixture())->records;
$displayQ = array();
foreach ($quizRec as $rec) {
$displayQ['List']['QuizFrameDisplayQuiz'][$rec['key']] = array(
'is_display' => array('1'), 'quiz_key' => $rec['key']);
}
$displayQ['List']['QuizFrameDisplayQuiz'] = array_values($displayQ['List']['QuizFrameDisplayQuiz']);
$displayQ['Single']['QuizFrameDisplayQuiz']['quiz_key'] = $quizRec[0]['key'];
$data = Hash::merge($data, $displayQ);
return $data;
}
/**
* edit()アクションDataProvider
*
* ### 戻り値
* - method: リクエストメソッド(get or post or put)
* - data: 登録データ
* - validationError: バリデーションエラー(省略可)
* - exception: Exception Error(省略可)
*
* @return array
*/
public function dataProviderEdit() {
$data = $this->__data();
//テストデータ
$results = array();
$results[0] = array('method' => 'get');
$results[1] = array('method' => 'post', 'data' => $data, 'validationError' => false);
$results[2] = array('method' => 'put', 'data' => $data, 'validationError' => false);
$results[3] = array('method' => 'put', 'data' => $data,
'validationError' => array(
'field' => 'QuizFrameSetting.display_type',
'value' => null, 'message' => __d('net_commons', 'Invalid request.')
),
);
return $results;
}
}