Commit 8eddde47a812dfeebecb339f0a826c588e89270f
Committed by
GitHub
Exists in
2.8
and in
8 other branches
Merge pull request #440 from vitormattos/feature/RegraTest
Implementar testes marcados como skipped em RegraTest.php
Showing
4 changed files
with
43 additions
and
323 deletions
Show diff stats
ieducar/lib/Portabilis/Controller/ApiCoreController.php
... | ... | @@ -320,7 +320,8 @@ class ApiCoreController extends Core_Controller_Page_EditController |
320 | 320 | $valid = true; |
321 | 321 | |
322 | 322 | foreach($requiredParamNames as $param) { |
323 | - if (! $this->validator->validatesPresenceOf($this->getRequest()->$param, $param) and $valid) { | |
323 | + $value = $this->getRequest()->$param; | |
324 | + if (! $this->validator->validatesPresenceOf($value, $param) and $valid) { | |
324 | 325 | $valid = false; |
325 | 326 | } |
326 | 327 | } | ... | ... |
ieducar/modules/Api/Views/RegraController.php
... | ... | @@ -162,7 +162,7 @@ class RegraController extends ApiCoreController |
162 | 162 | $__regras[$regra['id']]['media_recuperacao_paralela'] = $regra['media_recuperacao_paralela']; |
163 | 163 | $__regras[$regra['id']]['nota_maxima_geral'] = $regra['nota_maxima_geral']; |
164 | 164 | $__regras[$regra['id']]['nota_maxima_exame'] = $regra['nota_maxima_exame']; |
165 | - $__regras[$regra['id']]['turmas'] || $__regras[$regra['id']]['turmas'] = []; | |
165 | + $__regras[$regra['id']]['turmas'] = []; | |
166 | 166 | |
167 | 167 | if ($regra['turma_id']) { |
168 | 168 | $__regras[$regra['id']]['turmas'][] = [ | ... | ... |
ieducar/tests/Unit/Api/RegraTest.php
... | ... | @@ -5,6 +5,8 @@ namespace Tests\unit\Api; |
5 | 5 | use PHPUnit\DbUnit\DataSet\DefaultDataSet; |
6 | 6 | use Tests\SuiteTestCase\ApiTestCase; |
7 | 7 | use Tests\SuiteTestCase\TestCase; |
8 | +use PHPUnit\Framework\Constraint\JsonMatches; | |
9 | +use PHPUnit\Util\Json; | |
8 | 10 | |
9 | 11 | require_once __DIR__ . '/../../../modules/Api/Views/RegraController.php'; |
10 | 12 | |
... | ... | @@ -18,8 +20,8 @@ class RegraTest extends ApiTestCase |
18 | 20 | |
19 | 21 | public function testRegression() |
20 | 22 | { |
21 | - $this->markTestSkipped('must be revisited.'); | |
22 | 23 | $responseBody = $this->doAuthenticatedRequest('regras', ['instituicao_id' => 1, 'ano' => '2018']); |
24 | + | |
23 | 25 | $this->assertJsonStringEqualsJsonFile($this->getJsonFile('regra_json_valid.json'), $responseBody); |
24 | 26 | } |
25 | 27 | } | ... | ... |
ieducar/tests/Unit/assets/regra_json_valid.json
1 | 1 | { |
2 | + "any_error_msg": false, | |
3 | + "msgs": [], | |
4 | + "oper": "get", | |
2 | 5 | "regras": [ |
3 | 6 | { |
4 | 7 | "id": "2", |
8 | + "media_recuperacao_paralela": null, | |
9 | + "nota_maxima_exame": "10", | |
10 | + "nota_maxima_geral": "10", | |
11 | + "parecer_descritivo": "0", | |
5 | 12 | "regra_diferenciada_id": null, |
6 | 13 | "tabela_arredondamento_id": "2", |
7 | 14 | "tabela_arredondamento_id_conceitual": null, |
8 | 15 | "tipo_nota": "2", |
9 | 16 | "tipo_presenca": "2", |
10 | - "parecer_descritivo": "0", | |
11 | 17 | "tipo_recuperacao": "0", |
12 | - "media_recuperacao_paralela": null, | |
13 | - "nota_maxima_geral": "10", | |
14 | - "nota_maxima_exame": "10", | |
15 | 18 | "turmas": [] |
16 | 19 | }, |
17 | 20 | { |
18 | 21 | "id": "3", |
22 | + "media_recuperacao_paralela": null, | |
23 | + "nota_maxima_exame": "10", | |
24 | + "nota_maxima_geral": "10", | |
25 | + "parecer_descritivo": "6", | |
19 | 26 | "regra_diferenciada_id": null, |
20 | 27 | "tabela_arredondamento_id": "4", |
21 | 28 | "tabela_arredondamento_id_conceitual": null, |
22 | 29 | "tipo_nota": "1", |
23 | 30 | "tipo_presenca": "1", |
24 | - "parecer_descritivo": "6", | |
25 | 31 | "tipo_recuperacao": "0", |
26 | - "media_recuperacao_paralela": null, | |
27 | - "nota_maxima_geral": "10", | |
28 | - "nota_maxima_exame": "10", | |
29 | 32 | "turmas": [] |
30 | 33 | }, |
31 | 34 | { |
32 | 35 | "id": "4", |
36 | + "media_recuperacao_paralela": null, | |
37 | + "nota_maxima_exame": "10", | |
38 | + "nota_maxima_geral": "10", | |
39 | + "parecer_descritivo": "3", | |
33 | 40 | "regra_diferenciada_id": null, |
34 | 41 | "tabela_arredondamento_id": "6", |
35 | 42 | "tabela_arredondamento_id_conceitual": null, |
36 | 43 | "tipo_nota": "1", |
37 | 44 | "tipo_presenca": "1", |
38 | - "parecer_descritivo": "3", | |
39 | 45 | "tipo_recuperacao": "0", |
40 | - "media_recuperacao_paralela": null, | |
41 | - "nota_maxima_geral": "10", | |
42 | - "nota_maxima_exame": "10", | |
43 | - "turmas": [ | |
44 | - { | |
45 | - "turma_id": "701" | |
46 | - }, | |
47 | - { | |
48 | - "turma_id": "702" | |
49 | - }, | |
50 | - { | |
51 | - "turma_id": "703" | |
52 | - }, | |
53 | - { | |
54 | - "turma_id": "720" | |
55 | - }, | |
56 | - { | |
57 | - "turma_id": "721" | |
58 | - }, | |
59 | - { | |
60 | - "turma_id": "723" | |
61 | - }, | |
62 | - { | |
63 | - "turma_id": "724" | |
64 | - }, | |
65 | - { | |
66 | - "turma_id": "725" | |
67 | - }, | |
68 | - { | |
69 | - "turma_id": "733" | |
70 | - }, | |
71 | - { | |
72 | - "turma_id": "769" | |
73 | - }, | |
74 | - { | |
75 | - "turma_id": "771" | |
76 | - }, | |
77 | - { | |
78 | - "turma_id": "772" | |
79 | - }, | |
80 | - { | |
81 | - "turma_id": "775" | |
82 | - }, | |
83 | - { | |
84 | - "turma_id": "776" | |
85 | - }, | |
86 | - { | |
87 | - "turma_id": "779" | |
88 | - } | |
89 | - ] | |
46 | + "turmas": [] | |
90 | 47 | }, |
91 | 48 | { |
92 | 49 | "id": "5", |
50 | + "media_recuperacao_paralela": null, | |
51 | + "nota_maxima_exame": "10", | |
52 | + "nota_maxima_geral": "10", | |
53 | + "parecer_descritivo": "3", | |
93 | 54 | "regra_diferenciada_id": null, |
94 | 55 | "tabela_arredondamento_id": "3", |
95 | 56 | "tabela_arredondamento_id_conceitual": null, |
96 | 57 | "tipo_nota": "2", |
97 | 58 | "tipo_presenca": "1", |
98 | - "parecer_descritivo": "3", | |
99 | 59 | "tipo_recuperacao": "0", |
100 | - "media_recuperacao_paralela": null, | |
101 | - "nota_maxima_geral": "10", | |
102 | - "nota_maxima_exame": "10", | |
103 | - "turmas": [ | |
104 | - { | |
105 | - "turma_id": "689" | |
106 | - }, | |
107 | - { | |
108 | - "turma_id": "690" | |
109 | - }, | |
110 | - { | |
111 | - "turma_id": "691" | |
112 | - }, | |
113 | - { | |
114 | - "turma_id": "693" | |
115 | - }, | |
116 | - { | |
117 | - "turma_id": "694" | |
118 | - }, | |
119 | - { | |
120 | - "turma_id": "695" | |
121 | - }, | |
122 | - { | |
123 | - "turma_id": "696" | |
124 | - }, | |
125 | - { | |
126 | - "turma_id": "697" | |
127 | - }, | |
128 | - { | |
129 | - "turma_id": "699" | |
130 | - }, | |
131 | - { | |
132 | - "turma_id": "705" | |
133 | - }, | |
134 | - { | |
135 | - "turma_id": "706" | |
136 | - }, | |
137 | - { | |
138 | - "turma_id": "707" | |
139 | - }, | |
140 | - { | |
141 | - "turma_id": "708" | |
142 | - }, | |
143 | - { | |
144 | - "turma_id": "710" | |
145 | - }, | |
146 | - { | |
147 | - "turma_id": "711" | |
148 | - }, | |
149 | - { | |
150 | - "turma_id": "712" | |
151 | - }, | |
152 | - { | |
153 | - "turma_id": "713" | |
154 | - }, | |
155 | - { | |
156 | - "turma_id": "714" | |
157 | - }, | |
158 | - { | |
159 | - "turma_id": "715" | |
160 | - }, | |
161 | - { | |
162 | - "turma_id": "738" | |
163 | - }, | |
164 | - { | |
165 | - "turma_id": "739" | |
166 | - }, | |
167 | - { | |
168 | - "turma_id": "740" | |
169 | - }, | |
170 | - { | |
171 | - "turma_id": "741" | |
172 | - }, | |
173 | - { | |
174 | - "turma_id": "742" | |
175 | - }, | |
176 | - { | |
177 | - "turma_id": "743" | |
178 | - }, | |
179 | - { | |
180 | - "turma_id": "744" | |
181 | - }, | |
182 | - { | |
183 | - "turma_id": "745" | |
184 | - }, | |
185 | - { | |
186 | - "turma_id": "746" | |
187 | - }, | |
188 | - { | |
189 | - "turma_id": "747" | |
190 | - }, | |
191 | - { | |
192 | - "turma_id": "748" | |
193 | - }, | |
194 | - { | |
195 | - "turma_id": "750" | |
196 | - }, | |
197 | - { | |
198 | - "turma_id": "751" | |
199 | - }, | |
200 | - { | |
201 | - "turma_id": "752" | |
202 | - }, | |
203 | - { | |
204 | - "turma_id": "753" | |
205 | - }, | |
206 | - { | |
207 | - "turma_id": "755" | |
208 | - }, | |
209 | - { | |
210 | - "turma_id": "756" | |
211 | - }, | |
212 | - { | |
213 | - "turma_id": "757" | |
214 | - }, | |
215 | - { | |
216 | - "turma_id": "758" | |
217 | - }, | |
218 | - { | |
219 | - "turma_id": "759" | |
220 | - }, | |
221 | - { | |
222 | - "turma_id": "760" | |
223 | - }, | |
224 | - { | |
225 | - "turma_id": "761" | |
226 | - }, | |
227 | - { | |
228 | - "turma_id": "762" | |
229 | - }, | |
230 | - { | |
231 | - "turma_id": "763" | |
232 | - }, | |
233 | - { | |
234 | - "turma_id": "764" | |
235 | - }, | |
236 | - { | |
237 | - "turma_id": "787" | |
238 | - }, | |
239 | - { | |
240 | - "turma_id": "788" | |
241 | - } | |
242 | - ] | |
60 | + "turmas": [] | |
243 | 61 | }, |
244 | 62 | { |
245 | 63 | "id": "6", |
64 | + "media_recuperacao_paralela": null, | |
65 | + "nota_maxima_exame": "10", | |
66 | + "nota_maxima_geral": "10", | |
67 | + "parecer_descritivo": "0", | |
246 | 68 | "regra_diferenciada_id": "1", |
247 | 69 | "tabela_arredondamento_id": "1", |
248 | 70 | "tabela_arredondamento_id_conceitual": "5", |
249 | 71 | "tipo_nota": "3", |
250 | 72 | "tipo_presenca": "1", |
251 | - "parecer_descritivo": "0", | |
252 | 73 | "tipo_recuperacao": "0", |
253 | - "media_recuperacao_paralela": null, | |
254 | - "nota_maxima_geral": "10", | |
255 | - "nota_maxima_exame": "10", | |
256 | - "turmas": [ | |
257 | - { | |
258 | - "turma_id": "700" | |
259 | - }, | |
260 | - { | |
261 | - "turma_id": "704" | |
262 | - }, | |
263 | - { | |
264 | - "turma_id": "729" | |
265 | - }, | |
266 | - { | |
267 | - "turma_id": "730" | |
268 | - }, | |
269 | - { | |
270 | - "turma_id": "731" | |
271 | - }, | |
272 | - { | |
273 | - "turma_id": "732" | |
274 | - }, | |
275 | - { | |
276 | - "turma_id": "781" | |
277 | - }, | |
278 | - { | |
279 | - "turma_id": "782" | |
280 | - }, | |
281 | - { | |
282 | - "turma_id": "783" | |
283 | - }, | |
284 | - { | |
285 | - "turma_id": "784" | |
286 | - }, | |
287 | - { | |
288 | - "turma_id": "789" | |
289 | - } | |
290 | - ] | |
74 | + "turmas": [] | |
291 | 75 | }, |
292 | 76 | { |
293 | 77 | "id": "7", |
78 | + "media_recuperacao_paralela": null, | |
79 | + "nota_maxima_exame": "5", | |
80 | + "nota_maxima_geral": "5", | |
81 | + "parecer_descritivo": "0", | |
294 | 82 | "regra_diferenciada_id": "1", |
295 | 83 | "tabela_arredondamento_id": "1", |
296 | 84 | "tabela_arredondamento_id_conceitual": null, |
297 | 85 | "tipo_nota": "1", |
298 | 86 | "tipo_presenca": "1", |
299 | - "parecer_descritivo": "0", | |
300 | 87 | "tipo_recuperacao": "0", |
301 | - "media_recuperacao_paralela": null, | |
302 | - "nota_maxima_geral": "5", | |
303 | - "nota_maxima_exame": "5", | |
304 | 88 | "turmas": [] |
305 | 89 | }, |
306 | 90 | { |
307 | 91 | "id": "1", |
92 | + "media_recuperacao_paralela": null, | |
93 | + "nota_maxima_exame": "10", | |
94 | + "nota_maxima_geral": "10", | |
95 | + "parecer_descritivo": "0", | |
308 | 96 | "regra_diferenciada_id": "5", |
309 | 97 | "tabela_arredondamento_id": "6", |
310 | 98 | "tabela_arredondamento_id_conceitual": null, |
311 | 99 | "tipo_nota": "1", |
312 | 100 | "tipo_presenca": "2", |
313 | - "parecer_descritivo": "0", | |
314 | 101 | "tipo_recuperacao": "0", |
315 | - "media_recuperacao_paralela": null, | |
316 | - "nota_maxima_geral": "10", | |
317 | - "nota_maxima_exame": "10", | |
318 | - "turmas": [ | |
319 | - { | |
320 | - "turma_id": "717" | |
321 | - }, | |
322 | - { | |
323 | - "turma_id": "718" | |
324 | - }, | |
325 | - { | |
326 | - "turma_id": "719" | |
327 | - }, | |
328 | - { | |
329 | - "turma_id": "722" | |
330 | - }, | |
331 | - { | |
332 | - "turma_id": "726" | |
333 | - }, | |
334 | - { | |
335 | - "turma_id": "727" | |
336 | - }, | |
337 | - { | |
338 | - "turma_id": "728" | |
339 | - }, | |
340 | - { | |
341 | - "turma_id": "734" | |
342 | - }, | |
343 | - { | |
344 | - "turma_id": "735" | |
345 | - }, | |
346 | - { | |
347 | - "turma_id": "736" | |
348 | - }, | |
349 | - { | |
350 | - "turma_id": "766" | |
351 | - }, | |
352 | - { | |
353 | - "turma_id": "767" | |
354 | - }, | |
355 | - { | |
356 | - "turma_id": "768" | |
357 | - }, | |
358 | - { | |
359 | - "turma_id": "770" | |
360 | - }, | |
361 | - { | |
362 | - "turma_id": "773" | |
363 | - }, | |
364 | - { | |
365 | - "turma_id": "774" | |
366 | - }, | |
367 | - { | |
368 | - "turma_id": "777" | |
369 | - }, | |
370 | - { | |
371 | - "turma_id": "778" | |
372 | - }, | |
373 | - { | |
374 | - "turma_id": "780" | |
375 | - }, | |
376 | - { | |
377 | - "turma_id": "785" | |
378 | - }, | |
379 | - { | |
380 | - "turma_id": "786" | |
381 | - } | |
382 | - ] | |
102 | + "turmas": [] | |
383 | 103 | } |
384 | 104 | ], |
385 | - "oper": "get", | |
386 | - "resource": "regras", | |
387 | - "msgs": [], | |
388 | - "any_error_msg": false | |
389 | -} | |
390 | 105 | \ No newline at end of file |
106 | + "resource": "regras" | |
107 | +} | ... | ... |