Commit 904c0242a046fbde04bdfa223e5612234e09af75
1 parent
a1ba0562
Exists in
master
Adicionado suporte a cursos que não tenham '''padrão de ano escolar''', forçado …
…o boletim a usar a quantidade de etapas/módulos definidas na turma ao qual o aluno está matriculado
Showing
3 changed files
with
70 additions
and
3 deletions
Show diff stats
ieducar/lib/App/Model/IedFinder.php
... | ... | @@ -321,17 +321,36 @@ class App_Model_IedFinder extends CoreExt_Entity |
321 | 321 | $ano = $ano['ano']; |
322 | 322 | } |
323 | 323 | else { |
324 | - throw new App_Model_Exception('Vários anos em andamento. Problemas.'); | |
324 | + throw new App_Model_Exception('Existem vários anos escolares em andamento.'); | |
325 | 325 | } |
326 | 326 | |
327 | 327 | $anoLetivoModulo = self::addClassToStorage('clsPmieducarAnoLetivoModulo', |
328 | 328 | NULL, 'include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php'); |
329 | 329 | |
330 | 330 | $modulos = $anoLetivoModulo->lista($ano, $codEscola); |
331 | + } | |
332 | + else { | |
333 | + $matriculaTurma = self::addClassToStorage('clsPmieducarMatriculaTurma', | |
334 | + NULL, 'include/pmieducar/clsPmieducarMatriculaTurma.inc.php'); | |
335 | + | |
336 | + $matriculas = $matriculaTurma->lista($codMatricula); | |
331 | 337 | |
332 | - if (FALSE === $modulos) { | |
333 | - return 0; | |
338 | + if (is_array($matriculas)) { | |
339 | + $matricula = array_shift($matriculas); | |
340 | + $codTurma = $matricula['ref_cod_turma']; | |
341 | + } | |
342 | + else { | |
343 | + throw new App_Model_Exception('Aluno não enturmado.'); | |
334 | 344 | } |
345 | + | |
346 | + $turmaModulo = self::addClassToStorage('clsPmieducarTurmaModulo', | |
347 | + NULL, 'include/pmieducar/clsPmieducarTurmaModulo.inc.php'); | |
348 | + | |
349 | + $modulos = $turmaModulo->lista($codTurma); | |
350 | + } | |
351 | + | |
352 | + if (FALSE === $modulos) { | |
353 | + return 0; | |
335 | 354 | } |
336 | 355 | |
337 | 356 | return count($modulos); | ... | ... |
ieducar/lib/App/Model/Matricula.php
ieducar/tests/unit/App/Model/IedFinderTest.php
... | ... | @@ -361,4 +361,51 @@ class App_Model_IedFinderTest extends UnitBaseTest |
361 | 361 | |
362 | 362 | $this->assertEquals(4, $etapas); |
363 | 363 | } |
364 | + | |
365 | + public function testEtapasDeUmCursoAnoNaoPadrao() | |
366 | + { | |
367 | + // Curso não padrão | |
368 | + $returnCurso = array('cod_curso' => 1, 'carga_horaria' => 800, 'hora_falta' => (50 / 60), 'padrao_ano_escolar' => 0); | |
369 | + | |
370 | + $cursoMock = $this->getCleanMock('clsPmieducarCurso'); | |
371 | + $cursoMock->expects($this->any()) | |
372 | + ->method('detalhe') | |
373 | + ->will($this->returnValue($returnCurso)); | |
374 | + | |
375 | + CoreExt_Entity::addClassToStorage('clsPmieducarCurso', $cursoMock, NULL, TRUE); | |
376 | + | |
377 | + // Pega informação da turma | |
378 | + $returnMatriculaTurma = array( | |
379 | + array('ref_cod_matricula' => 1, 'ref_cod_turma' => 1) | |
380 | + ); | |
381 | + | |
382 | + $matriculaTurmaMock = $this->getCleanMock('clsPmieducarMatriculaTurma'); | |
383 | + $matriculaTurmaMock->expects($this->at(0)) | |
384 | + ->method('lista') | |
385 | + ->with(1) | |
386 | + ->will($this->returnValue($returnMatriculaTurma)); | |
387 | + | |
388 | + $returnTurmaModulo = array( | |
389 | + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 1), | |
390 | + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 2), | |
391 | + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 3), | |
392 | + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 4) | |
393 | + ); | |
394 | +new clsPmieducarTurmaModulo(); | |
395 | + $turmaModuloMock = $this->getCleanMock('clsPmieducarTurmaModulo'); | |
396 | + $turmaModuloMock->expects($this->at(0)) | |
397 | + ->method('lista') | |
398 | + ->with(1) | |
399 | + ->will($this->returnValue($returnTurmaModulo)); | |
400 | + | |
401 | + App_Model_IedFinder::addClassToStorage('clsPmieducarMatriculaTurma', | |
402 | + $matriculaTurmaMock, NULL, TRUE); | |
403 | + | |
404 | + App_Model_IedFinder::addClassToStorage('clsPmieducarTurmaModulo', | |
405 | + $turmaModuloMock, NULL, TRUE); | |
406 | + | |
407 | + $etapas = App_Model_IedFinder::getQuantidadeDeEtapasMatricula(1); | |
408 | + | |
409 | + $this->assertEquals(4, $etapas); | |
410 | + } | |
364 | 411 | } |
365 | 412 | \ No newline at end of file | ... | ... |