Skip to content

Commit

Permalink
555 refatoracao de testes (pengovbr#572)
Browse files Browse the repository at this point in the history
* feat: refatoracao de testes do ambiente sei4

* feat: refatoracao de testes do ambiente sei41

* feat: refatoracao de testes do ambiente super

---------

Co-authored-by: Paul Richard Pereira Martins dos Anjos <[email protected]>
  • Loading branch information
2 people authored and Glaydson Rodrigues committed Aug 28, 2024
1 parent a1dc73f commit 33da930
Show file tree
Hide file tree
Showing 20 changed files with 319 additions and 220 deletions.
35 changes: 29 additions & 6 deletions tests_sei4/funcional/tests/FixtureCenarioBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,21 @@ protected function cadastrarProcessoFixture(&$dadosProcesso)

protected function cadastrarDocumentoInternoFixture($dadosDocumentoInterno, $idProtocolo)
{
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
$dadosDocumentoDTO = [
'IdProtocolo' => $idProtocolo,
'IdProcedimento' => $idProtocolo,
'Descricao' => $dadosDocumentoInterno['DESCRICAO'],
'IdHipoteseLegal' => $dadosDocumentoInterno["HIPOTESE_LEGAL"] ?: null,
'StaNivelAcessoGlobal' => $dadosDocumentoInterno["RESTRICAO"] ?: \ProtocoloRN::$NA_PUBLICO,
'StaNivelAcessoLocal' => $dadosDocumentoInterno["RESTRICAO"] ?: \ProtocoloRN::$NA_PUBLICO,
]);
];

if ($serieDTO = $this->buscarIdSerieDoDocumento($dadosDocumentoInterno['TIPO_DOCUMENTO'])) {
$dadosDocumentoDTO['IdSerie'] = $serieDTO->getNumIdSerie();
}

$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar($dadosDocumentoDTO);

//Adicionar assinatura ao documento
$objAssinaturaFixture = new AssinaturaFixture();
Expand All @@ -85,15 +91,21 @@ protected function cadastrarDocumentoInternoFixture($dadosDocumentoInterno, $idP

protected function cadastrarDocumentoExternoFixture($dadosDocumentoExterno, $idProtocolo)
{
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
$dadosDocumentoDTO = [
'IdProtocolo' => $idProtocolo,
'IdProcedimento' => $idProtocolo,
'Descricao' => $dadosDocumentoExterno['DESCRICAO'],
'StaProtocolo' => \ProtocoloRN::$TP_DOCUMENTO_RECEBIDO,
'StaDocumento' => \DocumentoRN::$TD_EXTERNO,
'IdConjuntoEstilos' => NULL,
]);
];

if ($serieDTO = $this->buscarIdSerieDoDocumento($dadosDocumentoExterno['TIPO_DOCUMENTO'])) {
$dadosDocumentoDTO['IdSerie'] = $serieDTO->getNumIdSerie();
}

$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar($dadosDocumentoDTO);

//Adicionar anexo ao documento
$objAnexoFixture = new AnexoFixture();
Expand Down Expand Up @@ -218,4 +230,15 @@ public function realizarTramiteExternoSemvalidacaoNoRemetenteFixture(&$processoT
$this->realizarTramiteExternoFixture($processoTeste, $documentosTeste, $remetente, $destinatario, false);
}

protected function buscarIdSerieDoDocumento($tipoDocumento)
{
$serieDTO = new \SerieDTO();
$serieDTO->setStrNome($tipoDocumento);
$serieDTO->retNumIdSerie();
$serieDTO->setNumMaxRegistrosRetorno(1);

$objBD = new \SerieBD(\BancoSEI::getInstance());
return $objBD->consultar($serieDTO);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Tests\Funcional\Sei\Fixtures\ProtocoloFixture;

/**
* Testes de trâmite de processos contendo um documento movido
*
Expand All @@ -9,7 +11,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoContendoDocumentoMovidoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoMovidoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -41,22 +43,25 @@ public function test_tramitar_processo_contendo_documento_movido()
self::$documentoTeste1 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste2 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);

// Criar processo principal e processo secundário
$protocoloSecundarioTeste = $this->cadastrarProcessoFixture($processoSecundarioTeste);
self::$protocoloTeste = $this->cadastrarProcessoFixture(self::$processoTeste);

// Cadastrando documentos no processo principal
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste1, self::$protocoloTeste->getDblIdProtocolo());
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste2, self::$protocoloTeste->getDblIdProtocolo());

// Acessar sistema do this->REMETENTE do processo
self::$protocoloTeste = self::$protocoloTeste->getStrProtocoloFormatado();
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// Criar processo secundário para o qual o documento será movido
$protocoloSecundarioTeste = $this->cadastrarProcesso($processoSecundarioTeste);
$this->abrirProcesso(self::$protocoloTeste);

// Cadastrar novo processo de teste e incluir documentos a ser movido
$this->paginaBase->navegarParaControleProcesso();
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);
$this->cadastrarDocumentoExterno(self::$documentoTeste1);
// Movendo documento do processo principal para o processo secundário
$documentoParaMover = $this->paginaProcesso->listarDocumentos()[0];
$this->paginaProcesso->selecionarDocumento($documentoParaMover);
$this->paginaDocumento->navegarParaMoverDocumento();
$this->paginaMoverDocumento->moverDocumentoParaProcesso($protocoloSecundarioTeste, "Motivo de teste");

// Cadastramento de documento adicional
$this->cadastrarDocumentoInterno(self::$documentoTeste2);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->paginaMoverDocumento->moverDocumentoParaProcesso($protocoloSecundarioTeste->getStrProtocoloFormatado(), "Motivo de teste");

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
Expand Down Expand Up @@ -161,21 +166,32 @@ public function test_devolucao_processo_para_origem_com_novo_documento_movido()
$processoSecundarioTeste = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste3 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste4 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
putenv("DATABASE_HOST=org2-database");

// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
// Criar novo processo secundário na ORG 2
$protocoloSecundarioTeste = $this->cadastrarProcessoFixture($processoSecundarioTeste);

$protocoloSecundarioTeste = $this->cadastrarProcesso($processoSecundarioTeste);
// Criar novo documento externo no processo principal recebido na ORG 2
$parametros = [
'ProtocoloFormatado' => self::$protocoloTeste,
];
$objProtocoloFixture = new ProtocoloFixture();
$objProtocoloTesteDTO = $objProtocoloFixture->buscar($parametros)[0];
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste3, $objProtocoloTesteDTO->getDblIdProtocolo());

// Incluir novos documentos ao processo para ser movido
// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
$this->abrirProcesso(self::$protocoloTeste);
$this->cadastrarDocumentoExterno(self::$documentoTeste3);

// Acessando novo documento externo e movendo-o ao novo processo secundario da ORG 2
$listaDeDocumentos = $this->paginaProcesso->listarDocumentos();
$documentoParaMover = $listaDeDocumentos[array_key_last($listaDeDocumentos)];
$this->paginaProcesso->selecionarDocumento($documentoParaMover);
$this->paginaDocumento->navegarParaMoverDocumento();
$this->paginaMoverDocumento->moverDocumentoParaProcesso($protocoloSecundarioTeste, "Motivo de teste");
$this->paginaMoverDocumento->moverDocumentoParaProcesso($protocoloSecundarioTeste->getStrProtocoloFormatado(), "Motivo de teste");

// Cadastramento de documento adicional
$this->cadastrarDocumentoInterno(self::$documentoTeste4);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
// Cadastrando novo documento interno no processo principal
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste4, $objProtocoloTesteDTO->getDblIdProtocolo());

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoContendoVariosDocumentosTest extends CenarioBaseTestCase
class TramiteProcessoContendoVariosDocumentosTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function test_tramitar_processo_contendo_varios_documentos()

shuffle(self::$documentosTeste);

$this->realizarTramiteExternoSemvalidacaoNoRemetente(self::$processoTeste, self::$documentosTeste, self::$remetente, self::$destinatario);
$this->realizarTramiteExternoSemvalidacaoNoRemetenteFixture(self::$processoTeste, self::$documentosTeste, self::$remetente, self::$destinatario);
self::$protocoloTeste = self::$processoTeste["PROTOCOLO"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Execution Groups
* @group execute_parallel_with_two_group1
*/
class TramiteProcessoDocumentoNaoMapeadoDestinoTest extends CenarioBaseTestCase
class TramiteProcessoDocumentoNaoMapeadoDestinoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -45,22 +45,8 @@ public function test_tramitar_processo_contendo_documento_nao_mapeado_destino()
self::$documentoTeste = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
self::$documentoTeste['TIPO_DOCUMENTO'] = self::$destinatario['TIPO_DOCUMENTO_NAO_MAPEADO'];

// 1 - Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// 2 - Cadastrar novo processo de teste
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);

// 3 - Incluir Documentos no Processo
$this->cadastrarDocumentoInterno(self::$documentoTeste);

// 4 - Assinar documento interno criado anteriormente
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);

// 5 - Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
self::$protocoloTeste, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'],
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);
$this->realizarTramiteExternoSemvalidacaoNoRemetenteFixture(self::$processoTeste, self::$documentoTeste, self::$remetente, self::$destinatario);
self::$protocoloTeste = self::$processoTeste["PROTOCOLO"];
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Execution Groups
* @group execute_alone_group4
*/
class TramiteProcessoDocumentoNaoMapeadoOrigemTest extends CenarioBaseTestCase
class TramiteProcessoDocumentoNaoMapeadoOrigemTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -46,17 +46,15 @@ public function test_tramitar_processo_documento_interno_nao_mapeado()
self::$documentoTeste = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
self::$documentoTeste['TIPO_DOCUMENTO'] = self::$remetente['TIPO_DOCUMENTO_NAO_MAPEADO'];

// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// Cadastrar novo processo de teste
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);

// Incluir Documentos no Processo
$this->cadastrarDocumentoInterno(self::$documentoTeste);
self::$protocoloTeste = $this->cadastrarProcessoFixture(self::$processoTeste);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste, self::$protocoloTeste->getDblIdProtocolo());
self::$protocoloTeste = self::$protocoloTeste->getStrProtocoloFormatado();

// Assinar documento interno criado anteriormente
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
$this->abrirProcesso(self::$protocoloTeste);;

$tipoDocumento = mb_convert_encoding(self::$documentoTeste["TIPO_DOCUMENTO"], "ISO-8859-1");
$mensagemEsperada = sprintf("Não existe mapeamento de envio para %s no documento", $tipoDocumento);
Expand Down Expand Up @@ -84,14 +82,15 @@ public function test_tramitar_processo_documento_externo_nao_mapeado()
self::$documentoTeste = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste['TIPO_DOCUMENTO'] = self::$remetente['TIPO_DOCUMENTO_NAO_MAPEADO'];

// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// Cadastrar novo processo de teste
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);

// Incluir Documentos no Processo
$this->cadastrarDocumentoExterno(self::$documentoTeste);
self::$protocoloTeste = $this->cadastrarProcessoFixture(self::$processoTeste);
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste, self::$protocoloTeste->getDblIdProtocolo());
self::$protocoloTeste = self::$protocoloTeste->getStrProtocoloFormatado();

// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
$this->abrirProcesso(self::$protocoloTeste);

$tipoDocumento = mb_convert_encoding(self::$documentoTeste["TIPO_DOCUMENTO"], "ISO-8859-1");
$mensagemEsperada = sprintf("Não existe mapeamento de envio para %s no documento", $tipoDocumento);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoExtensaoNaoMapeadoDestinoTest extends CenarioBaseTestCase
class TramiteProcessoExtensaoNaoMapeadoDestinoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -31,12 +31,8 @@ public function test_tramitar_processo_contendo_extensao_nao_mapeada_destino()
self::$processoTeste = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste = $this->gerarDadosDocumentoExternoTeste(self::$remetente, 'arquivo_extensao_nao_permitida.docx');

$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);
$this->cadastrarDocumentoExterno(self::$documentoTeste);
$this->tramitarProcessoExternamente(
self::$protocoloTeste, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'],
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);
$this->realizarTramiteExternoSemvalidacaoNoRemetenteFixture(self::$processoTeste, self::$documentoTeste, self::$remetente, self::$destinatario);
self::$protocoloTeste = self::$processoTeste["PROTOCOLO"];
}


Expand Down
35 changes: 29 additions & 6 deletions tests_sei41/funcional/tests/FixtureCenarioBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,21 @@ protected function cadastrarProcessoFixture(&$dadosProcesso)

protected function cadastrarDocumentoInternoFixture($dadosDocumentoInterno, $idProtocolo)
{
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
$dadosDocumentoDTO = [
'IdProtocolo' => $idProtocolo,
'IdProcedimento' => $idProtocolo,
'Descricao' => $dadosDocumentoInterno['DESCRICAO'],
'IdHipoteseLegal' => $dadosDocumentoInterno["HIPOTESE_LEGAL"] ?: null,
'StaNivelAcessoGlobal' => $dadosDocumentoInterno["RESTRICAO"] ?: \ProtocoloRN::$NA_PUBLICO,
'StaNivelAcessoLocal' => $dadosDocumentoInterno["RESTRICAO"] ?: \ProtocoloRN::$NA_PUBLICO,
]);
];

if ($serieDTO = $this->buscarIdSerieDoDocumento($dadosDocumentoInterno['TIPO_DOCUMENTO'])) {
$dadosDocumentoDTO['IdSerie'] = $serieDTO->getNumIdSerie();
}

$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar($dadosDocumentoDTO);

//Adicionar assinatura ao documento
$objAssinaturaFixture = new AssinaturaFixture();
Expand All @@ -85,15 +91,21 @@ protected function cadastrarDocumentoInternoFixture($dadosDocumentoInterno, $idP

protected function cadastrarDocumentoExternoFixture($dadosDocumentoExterno, $idProtocolo)
{
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
$dadosDocumentoDTO = [
'IdProtocolo' => $idProtocolo,
'IdProcedimento' => $idProtocolo,
'Descricao' => $dadosDocumentoExterno['DESCRICAO'],
'StaProtocolo' => \ProtocoloRN::$TP_DOCUMENTO_RECEBIDO,
'StaDocumento' => \DocumentoRN::$TD_EXTERNO,
'IdConjuntoEstilos' => NULL,
]);
];

if ($serieDTO = $this->buscarIdSerieDoDocumento($dadosDocumentoExterno['TIPO_DOCUMENTO'])) {
$dadosDocumentoDTO['IdSerie'] = $serieDTO->getNumIdSerie();
}

$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar($dadosDocumentoDTO);

//Adicionar anexo ao documento
$objAnexoFixture = new AnexoFixture();
Expand Down Expand Up @@ -218,4 +230,15 @@ public function realizarTramiteExternoSemvalidacaoNoRemetenteFixture(&$processoT
$this->realizarTramiteExternoFixture($processoTeste, $documentosTeste, $remetente, $destinatario, false);
}

protected function buscarIdSerieDoDocumento($tipoDocumento)
{
$serieDTO = new \SerieDTO();
$serieDTO->setStrNome($tipoDocumento);
$serieDTO->retNumIdSerie();
$serieDTO->setNumMaxRegistrosRetorno(1);

$objBD = new \SerieBD(\BancoSEI::getInstance());
return $objBD->consultar($serieDTO);
}

}
Loading

0 comments on commit 33da930

Please sign in to comment.