1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace common\unit\models; |
4
|
|
|
|
5
|
|
|
use Yii; |
6
|
|
|
use Codeception\Specify; |
7
|
|
|
use common\models\Question; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Time test |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
class QuestionTest extends \Codeception\Test\Unit { |
14
|
|
|
use Specify; |
15
|
|
|
|
16
|
|
|
private $question; |
17
|
|
|
private $questionData = [ |
18
|
|
|
[ |
19
|
|
|
'id' => 487, |
20
|
|
|
'user_id' => 1, |
21
|
|
|
'behavior_id' => 54, |
22
|
|
|
'user_behavior_id' => 2664, |
23
|
|
|
'question' => 1, |
24
|
|
|
'answer' => 'test1', |
25
|
|
|
'date' => '2019-10-27 21:07:35', |
26
|
|
|
'category_id' => 4, |
27
|
|
|
], [ |
28
|
|
|
'id' => 488, |
29
|
|
|
'user_id' => 1, |
30
|
|
|
'behavior_id' => 54, |
31
|
|
|
'user_behavior_id' => 2664, |
32
|
|
|
'question' => 2, |
33
|
|
|
'answer' => 'test2', |
34
|
|
|
'date' => '2019-10-27 21:07:35', |
35
|
|
|
'category_id' => 4, |
36
|
|
|
], [ |
37
|
|
|
'id' => 489, |
38
|
|
|
'user_id' => 1, |
39
|
|
|
'behavior_id' => 54, |
40
|
|
|
'user_behavior_id' => 2664, |
41
|
|
|
'question' => 3, |
42
|
|
|
'answer' => 'test3', |
43
|
|
|
'date' => '2019-10-27 21:07:35', |
44
|
|
|
'category_id' => 4, |
45
|
|
|
], [ |
46
|
|
|
'id' => 490, |
47
|
|
|
'user_id' => 1, |
48
|
|
|
'behavior_id' => 132, |
49
|
|
|
'user_behavior_id' => 2665, |
50
|
|
|
'question' => 1, |
51
|
|
|
'answer' => 'test1', |
52
|
|
|
'date' => '2019-10-27 21:07:35', |
53
|
|
|
'category_id' => 7, |
54
|
|
|
], [ |
55
|
|
|
'id' => 491, |
56
|
|
|
'user_id' => 1, |
57
|
|
|
'behavior_id' => 132, |
58
|
|
|
'user_behavior_id' => 2665, |
59
|
|
|
'question' => 2, |
60
|
|
|
'answer' => 'test2', |
61
|
|
|
'date' => '2019-10-27 21:07:35', |
62
|
|
|
'category_id' => 7, |
63
|
|
|
], [ |
64
|
|
|
'id' => 492, |
65
|
|
|
'user_id' => 1, |
66
|
|
|
'behavior_id' => 132, |
67
|
|
|
'user_behavior_id' => 2665, |
68
|
|
|
'question' => 3, |
69
|
|
|
'answer' => 'test3', |
70
|
|
|
'date' => '2019-10-27 21:07:35', |
71
|
|
|
'category_id' => 7, |
72
|
|
|
], [ |
73
|
|
|
'id' => 493, |
74
|
|
|
'user_id' => 1, |
75
|
|
|
'behavior_id' => NULL, |
76
|
|
|
'user_behavior_id' => 2666, |
77
|
|
|
'question' => 1, |
78
|
|
|
'answer' => 'test1', |
79
|
|
|
'date' => '2019-10-27 21:07:35', |
80
|
|
|
'category_id' => 2, |
81
|
|
|
], [ |
82
|
|
|
'id' => 494, |
83
|
|
|
'user_id' => 1, |
84
|
|
|
'behavior_id' => NULL, |
85
|
|
|
'user_behavior_id' => 2666, |
86
|
|
|
'question' => 2, |
87
|
|
|
'answer' => 'test2', |
88
|
|
|
'date' => '2019-10-27 21:07:35', |
89
|
|
|
'category_id' => 2, |
90
|
|
|
], [ |
91
|
|
|
'id' => 495, |
92
|
|
|
'user_id' => 1, |
93
|
|
|
'behavior_id' => NULL, |
94
|
|
|
'user_behavior_id' => 2666, |
95
|
|
|
'question' => 3, |
96
|
|
|
'answer' => 'test3', |
97
|
|
|
'date' => '2019-10-27 21:07:35', |
98
|
|
|
'category_id' => 2, |
99
|
|
|
], |
100
|
|
|
]; |
101
|
|
|
private $userQuestions = [ |
102
|
|
|
13 => [ |
103
|
|
|
'question' => [ |
104
|
|
|
'id' => 13, |
105
|
|
|
'title' => 'less time/energy for God, meetings, and church', |
106
|
|
|
], |
107
|
|
|
'answers' => [ |
108
|
|
|
[ |
109
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
110
|
|
|
'answer' => 'alsgn', |
111
|
|
|
], [ |
112
|
|
|
'title' => 'How does it affect the important people in my life?', |
113
|
|
|
'answer' => 'loiun', |
114
|
|
|
], [ |
115
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
116
|
|
|
'answer' => 'liun', |
117
|
|
|
], |
118
|
|
|
], |
119
|
|
|
], |
120
|
|
|
29 => [ |
121
|
|
|
'question' => [ |
122
|
|
|
'id' => 29, |
123
|
|
|
'title' => 'using profanity', |
124
|
|
|
], |
125
|
|
|
'answers' => [ |
126
|
|
|
[ |
127
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
128
|
|
|
'answer' => 'ljnb', |
129
|
|
|
], [ |
130
|
|
|
'title' => 'How does it affect the important people in my life?', |
131
|
|
|
'answer' => 'liunb', |
132
|
|
|
], [ |
133
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
134
|
|
|
'answer' => 'ilub ', |
135
|
|
|
], |
136
|
|
|
], |
137
|
|
|
], |
138
|
|
|
48 => [ |
139
|
|
|
'question' => [ |
140
|
|
|
'id' => 48, |
141
|
|
|
'title' => 'workaholic', |
142
|
|
|
], |
143
|
|
|
'answers' => [ |
144
|
|
|
[ |
145
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
146
|
|
|
'answer' => 'liub', |
147
|
|
|
], [ |
148
|
|
|
'title' => 'How does it affect the important people in my life?', |
149
|
|
|
'answer' => 'liub', |
150
|
|
|
], [ |
151
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
152
|
|
|
'answer' => 'liub ', |
153
|
|
|
], |
154
|
|
|
], |
155
|
|
|
], |
156
|
|
|
89 => [ |
157
|
|
|
'question' => [ |
158
|
|
|
'id' => 89, |
159
|
|
|
'title' => 'obsessive (stuck) thoughts', |
160
|
|
|
], |
161
|
|
|
'answers' => [ |
162
|
|
|
[ |
163
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
164
|
|
|
'answer' => 'liub', |
165
|
|
|
], [ |
166
|
|
|
'title' => 'How does it affect the important people in my life?', |
167
|
|
|
'answer' => 'liuby', |
168
|
|
|
], [ |
169
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
170
|
|
|
'answer' => 'uiylb', |
171
|
|
|
], |
172
|
|
|
], |
173
|
|
|
], |
174
|
|
|
111 => [ |
175
|
|
|
'question' => [ |
176
|
|
|
'id' => 111, |
177
|
|
|
'title' => 'seeking out old unhealthy people and places', |
178
|
|
|
], |
179
|
|
|
'answers' => [ |
180
|
|
|
[ |
181
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
182
|
|
|
'answer' => 'liub', |
183
|
|
|
], [ |
184
|
|
|
'title' => 'How does it affect the important people in my life?', |
185
|
|
|
'answer' => 'liuyb', |
186
|
|
|
], [ |
187
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
188
|
|
|
'answer' => 'iuyb', |
189
|
|
|
], |
190
|
|
|
], |
191
|
|
|
], |
192
|
|
|
122 => [ |
193
|
|
|
'question' => [ |
194
|
|
|
'id' => 122, |
195
|
|
|
'title' => 'returning to the place you swore you would never go again', |
196
|
|
|
], |
197
|
|
|
'answers' => [ |
198
|
|
|
[ |
199
|
|
|
'title' => 'How does it affect me? How do I act and feel?', |
200
|
|
|
'answer' => 'iuyb', |
201
|
|
|
], [ |
202
|
|
|
'title' => 'How does it affect the important people in my life?', |
203
|
|
|
'answer' => 'iuyb', |
204
|
|
|
], [ |
205
|
|
|
'title' => 'Why do I do this? What is the benefit for me?', |
206
|
|
|
'answer' => 'liuyb', |
207
|
|
|
], |
208
|
|
|
], |
209
|
|
|
], |
210
|
|
|
]; |
211
|
|
|
|
212
|
|
|
public function setUp() { |
213
|
|
|
$this->question = $this->getMockBuilder('\common\models\Question') |
214
|
|
|
->setMethods(['save', 'attributes']) |
215
|
|
|
->getMock(); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function testParseQuestionData() { |
219
|
|
|
expect('parseQuestionData should return the correct structure with expected data', $this->assertEquals($this->question->parseQuestionData($this->questionData), $this->userQuestions)); |
|
|
|
|
220
|
|
|
expect('parseQuestionData should return empty with the empty set', $this->assertEmpty($this->question->parseQuestionData([]))); |
|
|
|
|
221
|
|
|
} |
222
|
|
|
} |
223
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.