Skip to content

Commit

Permalink
tests: refatoracao testes funcionais
Browse files Browse the repository at this point in the history
  • Loading branch information
marvdias committed Aug 2, 2024
1 parent c53f08b commit c74d1e6
Show file tree
Hide file tree
Showing 22 changed files with 251 additions and 506 deletions.
4 changes: 2 additions & 2 deletions tests_sei4/funcional/tests/FixtureCenarioBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function cadastrarProcessoFixture(&$dadosProcesso)
'IdAtividade' => $objAtividadeDTO->getNumIdAtividade()
]);

$dadosProcesso['PROTOCOLO'] = $protocoloGerado;
$dadosProcesso['PROTOCOLO'] = $objProtocoloDTO->getStrProtocoloFormatado();

return $objProtocoloDTO;
}
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function consultarProcessoFixture($protocoloFormatado, $staProtocolo)
'ProtocoloFormatado' => $protocoloFormatado,
'StaProtocolo' => $staProtocolo ?: \ProtocoloRN::$TP_DOCUMENTO_GERADO,
]);
return $objProtocoloDTO;
return $objProtocoloDTO[0];
}

protected function realizarTramiteExternoFixture(&$processoTeste, $documentosTeste, $remetente, $destinatario, $validarTramite)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Execution Groups
* @group execute_alone_group5
*/
class TramiteProcessoContendoDocumentoExternoMesmoOrgaoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoExternoMesmoOrgaoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -34,7 +34,7 @@ public function test_tramitar_processo_contendo_documento_gerado()
self::$destinatario['NOME_UNIDADE'] = self::$remetente['NOME_UNIDADE_SECUNDARIA'];
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'] = self::$remetente['SIGLA_UNIDADE_SECUNDARIA_HIERARQUIA'];

$this->realizarTramiteExternoSemvalidacaoNoRemetente(self::$processoTeste, self::$documentoTeste, self::$remetente, self::$destinatario);
$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 @@ -5,7 +5,7 @@
* @group rodarseparado2
* @group execute_alone_group1
*/
class TramiteProcessoContendoDocumentoExternoParticionadoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoExternoParticionadoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -14,7 +14,7 @@ class TramiteProcessoContendoDocumentoExternoParticionadoTest extends CenarioBas
public static $protocoloTeste;

public static function setUpBeforeClass() :void {

parent::setUpBeforeClass();
$bancoOrgaoA = new DatabaseUtils(CONTEXTO_ORGAO_A);
$bancoOrgaoA->execute("update infra_parametro set valor = ? where nome = ?", array(70, 'SEI_TAM_MB_DOC_EXTERNO'));
Expand Down Expand Up @@ -47,20 +47,27 @@ public function test_tramitar_processo_contendo_documento_externo_60mb()
// Configuração do dados para teste do cenário
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
putenv("DATABASE_HOST=org2-database");

self::$processoTeste = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste = $this->gerarDadosDocumentoExternoTeste(self::$remetente, 'arquivo_060.pdf');

$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);
$objProtocoloDTO = $this->cadastrarProcessoFixture(self::$processoTeste);
self::$protocoloTeste = $objProtocoloDTO->getStrProtocoloFormatado();

// Altera tamanho máximo permitido para permitir o envio de arquivo superior à 50MBs
$bancoOrgaoB = new DatabaseUtils(CONTEXTO_ORGAO_B);
try {
$bancoOrgaoB->execute("update infra_parametro set valor = ? where nome = ?", array(70, 'SEI_TAM_MB_DOC_EXTERNO'));
$this->cadastrarDocumentoExterno(self::$documentoTeste);
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste, $objProtocoloDTO->getDblIdProtocolo());
} finally {
$bancoOrgaoB->execute("update infra_parametro set valor = ? where nome = ?", array(50, 'SEI_TAM_MB_DOC_EXTERNO'));
}
putenv("DATABASE_HOST=org1-database");

$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

$this->abrirProcesso(self::$protocoloTeste);

$this->tramitarProcessoExternamente(
self::$protocoloTeste, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoContendoDocumentoGeradoMesmoOrgaoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoGeradoMesmoOrgaoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -33,7 +33,7 @@ public function test_tramitar_processo_contendo_documento_gerado()
self::$destinatario['NOME_UNIDADE'] = self::$remetente['NOME_UNIDADE_SECUNDARIA'];
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'] = self::$remetente['SIGLA_UNIDADE_SECUNDARIA_HIERARQUIA'];

$this->realizarTramiteExternoSemvalidacaoNoRemetente(self::$processoTeste, self::$documentoTeste, self::$remetente, self::$destinatario);
$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_group1
*/
class TramiteProcessoContendoDocumentoGeradoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoGeradoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -30,17 +30,19 @@ public function test_tramitar_processo_contendo_documento_gerado()
self::$processoTeste = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste = $this->gerarDadosDocumentoInternoTeste(self::$remetente);

// 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);
// 1 - Cadastrar novo processo de teste
$objProtocoloDTO = $this->cadastrarProcessoFixture(self::$processoTeste);
self::$protocoloTeste = $objProtocoloDTO->getStrProtocoloFormatado();

// 2 - Incluir Documentos no Processo
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste, $objProtocoloDTO->getDblIdProtocolo());

// 3 - Incluir Documentos no Processo
$this->cadastrarDocumentoInterno(self::$documentoTeste);
// 3 - Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

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

// 5 - 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 @@ -4,7 +4,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoContendoDocumentoInternoExternoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoInternoExternoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -32,20 +32,23 @@ public function test_tramitar_processo_contendo_documento_interno_externo()
self::$documentoInternoTeste = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
self::$documentoExternoTeste = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

// 1 - Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);
// 1 - Cadastrar novo processo de teste
$objProtocoloDTO = $this->cadastrarProcessoFixture(self::$processoTeste);
self::$protocoloTeste = $objProtocoloDTO->getStrProtocoloFormatado();

// 2 - Incluir e assinar documentos no processo
$this->cadastrarDocumentoInternoFixture(self::$documentoInternoTeste, $objProtocoloDTO->getDblIdProtocolo());

// 2 - Cadastrar novo processo de teste
self::$protocoloTeste = $this->cadastrarProcesso(self::$processoTeste);
// 3 - Incluir documento externo ao processo
$this->cadastrarDocumentoExternoFixture(self::$documentoExternoTeste, $objProtocoloDTO->getDblIdProtocolo());

// 3 - Incluir e assinar documentos no processo
$this->cadastrarDocumentoInterno(self::$documentoInternoTeste);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
// 4 - Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// 4 - Incluir documento externo ao processo
$this->cadastrarDocumentoExterno(self::$documentoExternoTeste);
// 5 - Abrir processo
$this->abrirProcesso(self::$protocoloTeste);

// 5 - Trâmitar Externamento processo para órgão/unidade destinatária
// 6 - 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);
Expand All @@ -70,7 +73,7 @@ public function test_verificar_origem_processo_contendo_documento_interno_extern

$this->abrirProcesso(self::$protocoloTeste);

// 6 - Verificar se situação atual do processo está como bloqueado
// 7 - Verificar se situação atual do processo está como bloqueado
$this->waitUntil(function($testCase) use (&$orgaosDiferentes) {
sleep(5);
$this->atualizarTramitesPEN();
Expand All @@ -82,15 +85,15 @@ public function test_verificar_origem_processo_contendo_documento_interno_extern
return true;
}, PEN_WAIT_TIMEOUT);

// 7 - Validar se recibo de trâmite foi armazenado para o processo (envio e conclusão)
// 8 - Validar se recibo de trâmite foi armazenado para o processo (envio e conclusão)
$unidade = mb_convert_encoding(self::$destinatario['NOME_UNIDADE'], "ISO-8859-1");
$mensagemRecibo = sprintf("Trâmite externo do Processo %s para %s", self::$protocoloTeste, $unidade);
$this->validarRecibosTramite($mensagemRecibo, true, true);

// 8 - Validar histórico de trâmite do processo
// 9 - Validar histórico de trâmite do processo
$this->validarHistoricoTramite(self::$destinatario['NOME_UNIDADE'], true, true);

// 9 - Verificar se processo está na lista de Processos Tramitados Externamente
// 10 - Verificar se processo está na lista de Processos Tramitados Externamente
$this->validarProcessosTramitados(self::$protocoloTeste, $orgaosDiferentes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* Execution Groups
* @group exxecute_parallel
*/
class TramiteProcessoContendoDocumentoMovidoDestinoTest extends CenarioBaseTestCase
class TramiteProcessoContendoDocumentoMovidoDestinoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -47,6 +47,10 @@ class TramiteProcessoContendoDocumentoMovidoDestinoTest extends CenarioBaseTestC
public static $documentoTeste5;
public static $documentoTeste6;
public static $documentoTeste7;
public static $objProtocoloTestePrincipalDTO;
public static $objProtocoloTestePrincipalOrg2DTO;



/*
Escopo da função:
Expand All @@ -68,27 +72,30 @@ public function test_criar_processo_contendo_documentos_tramitar_remetente()
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_B);

// acessar remetente (Órgão 1)
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// 1-criar Processo Principal ($processoTestePrincipal) (Órgão 1)
self::$processoTestePrincipal = $this->gerarDadosProcessoTeste(self::$remetente);
$this->paginaBase->navegarParaControleProcesso();
self::$protocoloTestePrincipal = $this->cadastrarProcesso(self::$processoTestePrincipal);
// $this->paginaBase->navegarParaControleProcesso();
self::$objProtocoloTestePrincipalDTO = $this->cadastrarProcessoFixture(self::$processoTestePrincipal);
self::$protocoloTestePrincipal = self::$objProtocoloTestePrincipalDTO->getStrProtocoloFormatado();

// 2-criar Documento Externo (documentoTeste1) no Processo Principal
self::$documentoTeste1 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
$this->cadastrarDocumentoExterno(self::$documentoTeste1);
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste1, self::$objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// 3-criar Documento Interno (documentoTeste2) no Processo Principal
self::$documentoTeste2 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
$this->cadastrarDocumentoInterno(self::$documentoTeste2);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste2, self::$objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// 4-criar Documento Interno (documentoTeste3) no Processo Principal
self::$documentoTeste3 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
$this->cadastrarDocumentoInterno(self::$documentoTeste3);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste3, self::$objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// acessar remetente (Órgão 1)
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// Abrir processo
$this->abrirProcesso(self::$protocoloTestePrincipal);

// 5-tramitar Processo Principal para o Órgão 2 com validação no remetente
$this->tramitarProcessoExternamente(self::$protocoloTestePrincipal, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'], self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);
Expand Down Expand Up @@ -146,9 +153,11 @@ public function test_criar_mover_incluir_documentos_devolver_processo_remetente(
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);

// 7-criar Processo Secundário ($processoTesteSecundario) (Órgão 2)
putenv("DATABASE_HOST=org2-database");
self::$processoTesteSecundario = $this->gerarDadosProcessoTeste(self::$remetente);
self::$protocoloTesteSecundario = $this->cadastrarProcesso(self::$processoTesteSecundario);

$objProtocoloSecundarioDTO = $this->cadastrarProcessoFixture(self::$processoTesteSecundario);
self::$protocoloTesteSecundario = $objProtocoloSecundarioDTO->getStrProtocoloFormatado();

// abrir Processo Principal
$this->abrirProcesso(self::$protocoloTestePrincipal);

Expand All @@ -166,15 +175,19 @@ public function test_criar_mover_incluir_documentos_devolver_processo_remetente(
$this->paginaDocumento->navegarParaMoverDocumento();
$this->paginaMoverDocumento->moverDocumentoParaProcesso(self::$protocoloTesteSecundario, "Motivo de teste");

// Consultar processo org-2
self::$objProtocoloTestePrincipalOrg2DTO = $this->consultarProcessoFixture(self::$protocoloTestePrincipal, $staProtocolo = 'P');

// 10-criar documento externo (documentoTeste4) no Processo Principal
self::$documentoTeste4 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
$this->cadastrarDocumentoExterno(self::$documentoTeste4);
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste4, self::$objProtocoloTestePrincipalOrg2DTO->getDblIdProtocolo());

// 11-criar documento interno (documentoTeste5) no Processo Principal
self::$documentoTeste5 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
$this->cadastrarDocumentoInterno(self::$documentoTeste5);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);

$this->cadastrarDocumentoInternoFixture(self::$documentoTeste5,self::$objProtocoloTestePrincipalOrg2DTO->getDblIdProtocolo());
// $this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);

putenv("DATABASE_HOST=org1-database");
// 12-tramitar Processo Principal para o Órgão 1 com validação no remetente
$this->tramitarProcessoExternamente(self::$protocoloTestePrincipal, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'], self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);

Expand Down Expand Up @@ -231,8 +244,7 @@ public function test_incluir_documento_tramitar_destinatario()

// 14-criar documento interno (documentoTeste6) no Processo Principal
self::$documentoTeste6 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
$this->cadastrarDocumentoInterno(self::$documentoTeste6);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste6, self::$objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// 15-tramitar Processo Principal para o Órgão 2 com validação no remetente
$this->tramitarProcessoExternamente(self::$protocoloTestePrincipal, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'], self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);
Expand Down Expand Up @@ -284,12 +296,13 @@ public function test_incluir_documento_tramitar_remetente()
// definir Órgão 1 como destinatário e Órgão 2 como remetente
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
putenv("DATABASE_HOST=org2-database");

// 17-criar documento interno (documentoTeste7) no Processo Principal
self::$documentoTeste7 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
$this->cadastrarDocumentoInterno(self::$documentoTeste7);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste7,self::$objProtocoloTestePrincipalOrg2DTO->getDblIdProtocolo());

putenv("DATABASE_HOST=org1-database");
// 18-tramitar Processo Principal para o Órgão 1 com validação no remetente
$this->tramitarProcessoExternamente(self::$protocoloTestePrincipal, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'], self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);

Expand Down
Loading

0 comments on commit c74d1e6

Please sign in to comment.