From 904c0242a046fbde04bdfa223e5612234e09af75 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Tue, 20 Apr 2010 19:51:58 +0000 Subject: [PATCH] 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 --- ieducar/lib/App/Model/IedFinder.php | 25 ++++++++++++++++++++++--- ieducar/lib/App/Model/Matricula.php | 1 + ieducar/tests/unit/App/Model/IedFinderTest.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/ieducar/lib/App/Model/IedFinder.php b/ieducar/lib/App/Model/IedFinder.php index 7d36a18..1939508 100644 --- a/ieducar/lib/App/Model/IedFinder.php +++ b/ieducar/lib/App/Model/IedFinder.php @@ -321,17 +321,36 @@ class App_Model_IedFinder extends CoreExt_Entity $ano = $ano['ano']; } else { - throw new App_Model_Exception('Vários anos em andamento. Problemas.'); + throw new App_Model_Exception('Existem vários anos escolares em andamento.'); } $anoLetivoModulo = self::addClassToStorage('clsPmieducarAnoLetivoModulo', NULL, 'include/pmieducar/clsPmieducarAnoLetivoModulo.inc.php'); $modulos = $anoLetivoModulo->lista($ano, $codEscola); + } + else { + $matriculaTurma = self::addClassToStorage('clsPmieducarMatriculaTurma', + NULL, 'include/pmieducar/clsPmieducarMatriculaTurma.inc.php'); + + $matriculas = $matriculaTurma->lista($codMatricula); - if (FALSE === $modulos) { - return 0; + if (is_array($matriculas)) { + $matricula = array_shift($matriculas); + $codTurma = $matricula['ref_cod_turma']; + } + else { + throw new App_Model_Exception('Aluno não enturmado.'); } + + $turmaModulo = self::addClassToStorage('clsPmieducarTurmaModulo', + NULL, 'include/pmieducar/clsPmieducarTurmaModulo.inc.php'); + + $modulos = $turmaModulo->lista($codTurma); + } + + if (FALSE === $modulos) { + return 0; } return count($modulos); diff --git a/ieducar/lib/App/Model/Matricula.php b/ieducar/lib/App/Model/Matricula.php index fdc782d..fc88ae3 100644 --- a/ieducar/lib/App/Model/Matricula.php +++ b/ieducar/lib/App/Model/Matricula.php @@ -29,6 +29,7 @@ */ require_once 'CoreExt/Entity.php'; +require_once 'App/Model/MatriculaSituacao.php'; /** * App_Model_Matricula class. diff --git a/ieducar/tests/unit/App/Model/IedFinderTest.php b/ieducar/tests/unit/App/Model/IedFinderTest.php index 550e601..32d30c1 100644 --- a/ieducar/tests/unit/App/Model/IedFinderTest.php +++ b/ieducar/tests/unit/App/Model/IedFinderTest.php @@ -361,4 +361,51 @@ class App_Model_IedFinderTest extends UnitBaseTest $this->assertEquals(4, $etapas); } + + public function testEtapasDeUmCursoAnoNaoPadrao() + { + // Curso não padrão + $returnCurso = array('cod_curso' => 1, 'carga_horaria' => 800, 'hora_falta' => (50 / 60), 'padrao_ano_escolar' => 0); + + $cursoMock = $this->getCleanMock('clsPmieducarCurso'); + $cursoMock->expects($this->any()) + ->method('detalhe') + ->will($this->returnValue($returnCurso)); + + CoreExt_Entity::addClassToStorage('clsPmieducarCurso', $cursoMock, NULL, TRUE); + + // Pega informação da turma + $returnMatriculaTurma = array( + array('ref_cod_matricula' => 1, 'ref_cod_turma' => 1) + ); + + $matriculaTurmaMock = $this->getCleanMock('clsPmieducarMatriculaTurma'); + $matriculaTurmaMock->expects($this->at(0)) + ->method('lista') + ->with(1) + ->will($this->returnValue($returnMatriculaTurma)); + + $returnTurmaModulo = array( + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 1), + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 2), + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 3), + array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 4) + ); +new clsPmieducarTurmaModulo(); + $turmaModuloMock = $this->getCleanMock('clsPmieducarTurmaModulo'); + $turmaModuloMock->expects($this->at(0)) + ->method('lista') + ->with(1) + ->will($this->returnValue($returnTurmaModulo)); + + App_Model_IedFinder::addClassToStorage('clsPmieducarMatriculaTurma', + $matriculaTurmaMock, NULL, TRUE); + + App_Model_IedFinder::addClassToStorage('clsPmieducarTurmaModulo', + $turmaModuloMock, NULL, TRUE); + + $etapas = App_Model_IedFinder::getQuantidadeDeEtapasMatricula(1); + + $this->assertEquals(4, $etapas); + } } \ No newline at end of file -- libgit2 0.21.2