Commit 2c2ce46656e3a85eab3905ca18d681d95c9fdbfc
1 parent
bcc715ae
Exists in
master
Corrigido bug durante a criação de mapper de {{{Avaliacao_Model_ParecerDescritiv…
…oAbstractDataMapper}}} padrão e de configuração de mocks para os testes de pareceres descritivos
Showing
3 changed files
with
28 additions
and
5 deletions
Show diff stats
ieducar/modules/Avaliacao/Service/Boletim.php
... | ... | @@ -589,6 +589,11 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
589 | 589 | break; |
590 | 590 | } |
591 | 591 | |
592 | + // Se não usar parecer descritivo, retorna NULL | |
593 | + if (!isset($filename)) { | |
594 | + return NULL; | |
595 | + } | |
596 | + | |
592 | 597 | require_once $filename; |
593 | 598 | $this->setParecerDescritivoAbstractDataMapper(new $class()); |
594 | 599 | } |
... | ... | @@ -888,6 +893,10 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
888 | 893 | */ |
889 | 894 | protected function _loadParecerDescritivo() |
890 | 895 | { |
896 | + if ($this->getRegra()->get('parecerDescritivo') == RegraAvaliacao_Model_TipoParecerDescritivo::NENHUM) { | |
897 | + return $this; | |
898 | + } | |
899 | + | |
891 | 900 | if (!$this->hasParecerDescritivoAluno()) { |
892 | 901 | $this->_createParecerDescritivoAluno(); |
893 | 902 | } | ... | ... |
ieducar/modules/Avaliacao/_tests/Service/ParecerDescritivoAlunoTest.php
... | ... | @@ -44,6 +44,12 @@ require_once 'Avaliacao/_tests/Service/TestCommon.php'; |
44 | 44 | */ |
45 | 45 | class Avaliacao_Service_ParecerDescritivoAlunoTest extends Avaliacao_Service_TestCommon |
46 | 46 | { |
47 | + protected function setUp() | |
48 | + { | |
49 | + $this->_setRegraOption('parecerDescritivo', RegraAvaliacao_Model_TipoParecerDescritivo::ANUAL_COMPONENTE); | |
50 | + parent::setUp(); | |
51 | + } | |
52 | + | |
47 | 53 | public function testCriaNovaInstanciaDeParecerDescritivoAluno() |
48 | 54 | { |
49 | 55 | $parecerAluno = $this->_getConfigOption('parecerDescritivoAluno', 'instance'); | ... | ... |
ieducar/modules/Avaliacao/_tests/Service/TestCommon.php
... | ... | @@ -915,10 +915,15 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
915 | 915 | $parecerAluno = $this->_getConfigOption('parecerDescritivoAluno', 'instance'); |
916 | 916 | |
917 | 917 | $mock = $this->getCleanMock('Avaliacao_Model_ParecerDescritivoAlunoDataMapper'); |
918 | - $mock->expects($this->at(0)) | |
919 | - ->method('findAll') | |
920 | - ->with(array(), array('matricula' => $this->_getConfigOption('matricula', 'cod_matricula'))) | |
921 | - ->will($this->returnValue(array($parecerAluno))); | |
918 | + | |
919 | + if ($this->_getRegraOption('parecerDescritivo') != RegraAvaliacao_Model_TipoParecerDescritivo::NENHUM) { | |
920 | + $matcher = $this->at(0); | |
921 | + | |
922 | + $mock->expects($matcher) | |
923 | + ->method('findAll') | |
924 | + ->with(array(), array('matricula' => $this->_getConfigOption('matricula', 'cod_matricula'))) | |
925 | + ->will($this->returnValue(array($parecerAluno))); | |
926 | + } | |
922 | 927 | |
923 | 928 | $this->_setParecerDescritivoAlunoDataMapperMock($mock); |
924 | 929 | } |
... | ... | @@ -938,10 +943,13 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
938 | 943 | $parecerAluno = $this->_getConfigOption('parecerDescritivoAluno', 'instance'); |
939 | 944 | |
940 | 945 | $mock = $this->getCleanMock('Avaliacao_Model_ParecerDescritivoAbstractDataMapper'); |
941 | - $mock->expects($this->at(0)) | |
946 | + | |
947 | + if ($this->_getRegraOption('parecerDescritivo') != RegraAvaliacao_Model_TipoParecerDescritivo::NENHUM) { | |
948 | + $mock->expects($this->at(0)) | |
942 | 949 | ->method('findAll') |
943 | 950 | ->with(array(), array('parecerDescritivoAluno' => $parecerAluno->id), array('etapa' => 'ASC')) |
944 | 951 | ->will($this->returnValue(array())); |
952 | + } | |
945 | 953 | |
946 | 954 | $this->_setParecerDescritivoAbstractDataMapperMock($mock); |
947 | 955 | } | ... | ... |