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 9, 2024
1 parent 59baf7a commit ee74f6e
Show file tree
Hide file tree
Showing 21 changed files with 298 additions and 141 deletions.
18 changes: 15 additions & 3 deletions tests_sei4/funcional/tests/FixtureCenarioBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Tests\Funcional\Sei\Fixtures\{ProtocoloFixture,ProcedimentoFixture,AtividadeFixture,ContatoFixture};
use Tests\Funcional\Sei\Fixtures\{ParticipanteFixture,RelProtocoloAssuntoFixture,AtributoAndamentoFixture};
use Tests\Funcional\Sei\Fixtures\{DocumentoFixture,AssinaturaFixture,AnexoFixture,AnexoProcessoFixture};
use Tests\Funcional\Sei\Fixtures\{HipoteseLegalFixture};

use function PHPSTORM_META\map;
/**
Expand All @@ -14,9 +15,21 @@ class FixtureCenarioBaseTestCase extends CenarioBaseTestCase
{
protected function cadastrarProcessoFixture(&$dadosProcesso)
{

if (!is_null($dadosProcesso['HIPOTESE_LEGAL'])){
$param = [
'Nome' => trim(explode('(',$dadosProcesso['HIPOTESE_LEGAL'])[0]),
'BaseLegal' => explode(')',trim(explode('(',$dadosProcesso['HIPOTESE_LEGAL'])[1]))[0]
];
$objHipLegalFixture = new HipoteseLegalFixture();
$objHipLegalDTO = $objHipLegalFixture->buscar($param)[0];
}

$parametros = [
'Descricao' => $dadosProcesso['DESCRICAO'] ?: util::random_string(20),
'Interessados' => $dadosProcesso['INTERESSADOS'] ?: util::random_string(40),
'IdHipoteseLegal' => $dadosProcesso['HIPOTESE_LEGAL'] ? $objHipLegalDTO->getNumIdHipoteseLegal() : null,
'StaNivelAcessoLocal' => $dadosProcesso["RESTRICAO"] ?: PaginaIniciarProcesso::STA_NIVEL_ACESSO_PUBLICO,
'StaNivelAcessoGlobal' => $dadosProcesso["RESTRICAO"] ?: PaginaIniciarProcesso::STA_NIVEL_ACESSO_PUBLICO
];
$objProtocoloFixture = new ProtocoloFixture();
Expand Down Expand Up @@ -113,7 +126,7 @@ protected function anexarProcessoFixture($protocoloPrincipalId, $protocoloProces
'IdDocumento' => $protocoloProcessoAnexadoId,
]);
}

protected function consultarProcessoFixture($protocoloFormatado, $staProtocolo)
{
$objProtocoloFixture = new ProtocoloFixture();
Expand All @@ -123,7 +136,7 @@ protected function consultarProcessoFixture($protocoloFormatado, $staProtocolo)
]);
return $objProtocoloDTO;
}

protected function realizarTramiteExternoFixture(&$processoTeste, $documentosTeste, $remetente, $destinatario, $validarTramite)
{
$orgaosDiferentes = $remetente['URL'] != $destinatario['URL'];
Expand Down Expand Up @@ -170,7 +183,6 @@ protected function realizarTramiteExternoFixture(&$processoTeste, $documentosTes
// 6 - Verificar se situação atual do processo está como bloqueado
$this->waitUntil(function ($testCase) use (&$orgaosDiferentes) {
sleep(5);
$this->atualizarTramitesPEN();
$testCase->refresh();
$paginaProcesso = new PaginaProcesso($testCase);
$testCase->assertStringNotContainsString(utf8_encode("Processo em trâmite externo para "), $paginaProcesso->informacao());
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 TramiteProcessoRestritoHipotesePadraoTest extends CenarioBaseTestCase
class TramiteProcessoRestritoHipotesePadraoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -35,17 +35,18 @@ public function test_tramitar_processo_restrito_hipotese_nao_mapeada()
self::$processoTeste["RESTRICAO"] = PaginaIniciarProcesso::STA_NIVEL_ACESSO_RESTRITO;
self::$processoTeste["HIPOTESE_LEGAL"] = self::$remetente["HIPOTESE_RESTRICAO_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);
$objProtocoloDTO = $this->cadastrarProcessoFixture(self::$processoTeste);
self::$protocoloTeste = $objProtocoloDTO->getStrProtocoloFormatado();

// Incluir Documentos no Processo
$this->cadastrarDocumentoInterno(self::$documentoTeste);
// Incluir e assinar documento no processo
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste, $objProtocoloDTO->getDblIdProtocolo());

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

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

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
Expand Down
13 changes: 7 additions & 6 deletions tests_sei4/funcional/tests/TramiteProcessoRestritoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Execution Groups
* @group execute_parallel_group1
*/
class TramiteProcessoRestritoTest extends CenarioBaseTestCase
class TramiteProcessoRestritoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -40,13 +40,14 @@ public function test_tramitar_processo_restrito()
$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);
$objProtocoloDTO = $this->cadastrarProcessoFixture(self::$processoTeste);
self::$protocoloTeste = $objProtocoloDTO->getStrProtocoloFormatado();

// Incluir Documentos no Processo
$this->cadastrarDocumentoInterno(self::$documentoTeste);
// Incluir e assinar documento no processo
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste, $objProtocoloDTO->getDblIdProtocolo());

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

// 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_alone_group3
*/
class TramiteProcessoTamanhoAcimaLimiteDestinoTest extends CenarioBaseTestCase
class TramiteProcessoTamanhoAcimaLimiteDestinoTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -22,7 +22,6 @@ class TramiteProcessoTamanhoAcimaLimiteDestinoTest extends CenarioBaseTestCase
*/
public static function setUpBeforeClass() :void {

parent::setUpBeforeClass();
// Redução de limite máximo de tamanho de documento externo
$bancoOrgaoB = new DatabaseUtils(CONTEXTO_ORGAO_B);
$bancoOrgaoB->execute("update infra_parametro set valor = ? where nome = ?", array(2, 'SEI_TAM_MB_DOC_EXTERNO'));
Expand Down Expand Up @@ -54,10 +53,17 @@ public function test_tramitar_processo_tamanho_acima_limite_destino()
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$processoTeste = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste = $this->gerarDadosDocumentoExternoTeste(self::$remetente, 'arquivo_003.pdf');

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

$this->cadastrarDocumentoExternoFixture(self::$documentoTeste, $objProtocoloDTO->getDblIdProtocolo());

$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->abrirProcesso(self::$protocoloTeste);

$this->tramitarProcessoExternamente(
self::$protocoloTeste, self::$destinatario['REP_ESTRUTURAS'], self::$destinatario['NOME_UNIDADE'],
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'], false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class TramiteProcessoUnidadeSemHierarquiaPaiTest extends CenarioBaseTestCase
class TramiteProcessoUnidadeSemHierarquiaPaiTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -27,7 +27,7 @@ public function test_tramitar_processo_da_origem()
self::$documentoTeste1 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);

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

$paginaProcesso = new PaginaProcesso($this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Execution Groups
* @group execute_alone_group6
*/
class TramiteProcessosComDevolucaoAmbosAnexadosTest extends CenarioBaseTestCase
class TramiteProcessosComDevolucaoAmbosAnexadosTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function test_tramitar_processos_separados_da_origem()
self::$documentoTeste2 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

$documentos = array(self::$documentoTeste1, self::$documentoTeste2);
$this->realizarTramiteExternoComValidacaoNoRemetente(self::$processoTestePrincipal, $documentos, self::$remetente, self::$destinatario);
$this->realizarTramiteExternoComValidacaoNoRemetenteFixture(self::$processoTestePrincipal, $documentos, self::$remetente, self::$destinatario);
self::$protocoloTestePrincipal = self::$processoTestePrincipal["PROTOCOLO"];

$this->sairSistema();
Expand All @@ -55,7 +55,7 @@ public function test_tramitar_processos_separados_da_origem()
self::$documentoTeste4 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

$documentos = array(self::$documentoTeste3, self::$documentoTeste4);
$this->realizarTramiteExternoComValidacaoNoRemetente(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);
$this->realizarTramiteExternoComValidacaoNoRemetenteFixture(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);
self::$protocoloTesteAnexado = self::$processoTesteAnexado["PROTOCOLO"];
}

Expand Down Expand Up @@ -96,21 +96,30 @@ public function test_devolucao_processo_anexado_para_origem()
{
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
putenv("DATABASE_HOST=org2-database");

// Definição de dados de teste do processo principal
self::$documentoTeste5 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste6 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

$objProtocoloAnexadoDTO = $this->consultarProcessoFixture(self::$protocoloTesteAnexado, \ProtocoloRN::$TP_PROCEDIMENTO);
$objProtocoloPrincipalDTO = $this->consultarProcessoFixture(self::$protocoloTestePrincipal, \ProtocoloRN::$TP_PROCEDIMENTO);

// Cadastra documento Externo ao processo anexado
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste5, $objProtocoloAnexadoDTO->getDblIdProtocolo());

// Anexa processo ao processo principal
$this->anexarProcessoFixture($objProtocoloPrincipalDTO->getDblIdProtocolo(), $objProtocoloAnexadoDTO->getDblIdProtocolo());

// Cadastra documento Externo ao processo principal
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste6, $objProtocoloPrincipalDTO->getDblIdProtocolo());

putenv("DATABASE_HOST=org1-database");

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

// Incluir novos documentos relacionados no processo anexado
$this->abrirProcesso(self::$protocoloTesteAnexado);
$this->cadastrarDocumentoExterno(self::$documentoTeste5);

$this->abrirProcesso(self::$protocoloTestePrincipal);
$this->anexarProcesso(self::$protocoloTesteAnexado);
$this->cadastrarDocumentoExterno(self::$documentoTeste6);

// 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 @@ -15,7 +15,7 @@
* Execution Groups
* @group execute_alone_group2
*/
class TramiteProcessosComDevolucoesEAnexacoesTest extends CenarioBaseTestCase
class TramiteProcessosComDevolucoesEAnexacoesTest extends FixtureCenarioBaseTestCase
{
public static $remetente;
public static $destinatario;
Expand All @@ -31,6 +31,11 @@ class TramiteProcessosComDevolucoesEAnexacoesTest extends CenarioBaseTestCase
public static $documentoTeste8;
public static $protocoloTestePrincipal;
public static $protocoloTesteAnexado;
public static $objProtocoloTestePrincipalDTO;
public static $objProtocoloTesteAnexadoDTO;




/**
* Teste inicial de trâmite de processo apartado para o órgão B
Expand All @@ -53,7 +58,7 @@ public function test_tramitar_processo_simples_para_orgaoB()
self::$documentoTeste2 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

$documentos = array(self::$documentoTeste1, self::$documentoTeste2);
$this->realizarTramiteExternoComValidacaoNoRemetente(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);
$this->realizarTramiteExternoComValidacaoNoRemetenteFixture(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);
self::$protocoloTesteAnexado = self::$processoTesteAnexado["PROTOCOLO"];
}

Expand Down Expand Up @@ -89,13 +94,16 @@ public function test_devolucao_processo_simples_para_origem()
{
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
putenv("DATABASE_HOST=org2-database");

// Definição de dados de teste do processo principal
self::$documentoTeste3 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
self::$documentoTeste4 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

$documentos = array(self::$documentoTeste3, self::$documentoTeste4);
$this->realizarTramiteExternoComValidacaoNoRemetente(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);
$this->realizarTramiteExternoComValidacaoNoRemetenteFixture(self::$processoTesteAnexado, $documentos, self::$remetente, self::$destinatario);

putenv("DATABASE_HOST=org1-database");
}


Expand Down Expand Up @@ -137,20 +145,23 @@ public function test_tramitar_processo_anexado_para_orgaoB()
self::$documentoTeste5 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste6 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);

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

$this->cadastrarDocumentoExternoFixture(self::$documentoTeste5, $objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// Cadastrar novo processo de teste principal e incluir documentos relacionados
$this->paginaBase->navegarParaControleProcesso();
self::$protocoloTestePrincipal = $this->cadastrarProcesso(self::$processoTestePrincipal);
$this->cadastrarDocumentoExterno(self::$documentoTeste5);
$objProtocoloTesteAnexadoDTO = $this->consultarProcessoFixture(self::$protocoloTesteAnexado, \ProtocoloRN::$TP_PROCEDIMENTO);

// Realizar a anexação de processos
$this->anexarProcesso(self::$protocoloTesteAnexado);
$this->anexarProcessoFixture($objProtocoloTestePrincipalDTO->getDblIdProtocolo(), $objProtocoloTesteAnexadoDTO->getDblIdProtocolo());

$this->cadastrarDocumentoInterno(self::$documentoTeste6);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste6, $objProtocoloTestePrincipalDTO->getDblIdProtocolo());

// 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::$protocoloTestePrincipal);

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
self::$protocoloTestePrincipal,
Expand Down Expand Up @@ -260,6 +271,7 @@ public function test_devolucao_processo_para_origem()
{
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);
putenv("DATABASE_HOST=org2-database");

// Definição de dados de teste do processo principal
self::$documentoTeste7 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
Expand All @@ -268,11 +280,16 @@ public function test_devolucao_processo_para_origem()
// Acessar sistema do this->REMETENTE do processo
$this->acessarSistema(self::$remetente['URL'], self::$remetente['SIGLA_UNIDADE'], self::$remetente['LOGIN'], self::$remetente['SENHA']);

// Consulta no Org2/B o DTO do Protocolo Principal
$objProtocoloTestePrincipalDTO = $this->consultarProcessoFixture(self::$protocoloTestePrincipal, \ProtocoloRN::$TP_PROCEDIMENTO);

// Incluir novos documentos relacionados
$this->cadastrarDocumentoExternoFixture(self::$documentoTeste7, $objProtocoloTestePrincipalDTO->getDblIdProtocolo());
$this->cadastrarDocumentoInternoFixture(self::$documentoTeste8, $objProtocoloTestePrincipalDTO->getDblIdProtocolo());

putenv("DATABASE_HOST=org1-database");

$this->abrirProcesso(self::$protocoloTestePrincipal);
$this->cadastrarDocumentoExterno(self::$documentoTeste7);
$this->cadastrarDocumentoInterno(self::$documentoTeste8);
$this->assinarDocumento(self::$remetente['ORGAO'], self::$remetente['CARGO_ASSINATURA'], self::$remetente['SENHA']);

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
Expand Down
Loading

0 comments on commit ee74f6e

Please sign in to comment.