Skip to content

Commit

Permalink
test: refatorar TramiteProcessoAnexoComDevolucaoTeste TramiteProcesso…
Browse files Browse the repository at this point in the history
…AnexadoTest com rebase para release 3.6.0
  • Loading branch information
marvdias committed Mar 25, 2024
1 parent 266418c commit d1800ad
Show file tree
Hide file tree
Showing 4 changed files with 518 additions and 112 deletions.
184 changes: 152 additions & 32 deletions tests_sei4/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Tests\Funcional\Sei\Fixtures\{ProtocoloFixture,ProcedimentoFixture,AtividadeFixture,ContatoFixture,ParticipanteFixture,RelProtocoloAssuntoFixture,AtributoAndamentoFixture,DocumentoFixture,AssinaturaFixture,AnexoFixture,AnexoProcessoFixture};

/**
* Testes de trâmite de processos anexado considerando a devolução do mesmo para a entidade de origem
* Execution Groups
Expand All @@ -19,6 +21,8 @@ class TramiteProcessoAnexadoComDevolucaoTest extends CenarioBaseTestCase
public static $documentoTeste6;
public static $protocoloTestePrincipal;
public static $protocoloTesteAnexado;
public static $protocoloTesteAnexadoId;
public static $protocoloTestePrincipalId;

/**
* Teste inicial de trâmite de um processo contendo outro anexado
Expand All @@ -37,31 +41,110 @@ public function test_tramitar_processo_anexado_da_origem()

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

// Definição de dados de teste do processo a ser anexado
self::$processoTesteAnexado = $this->gerarDadosProcessoTeste(self::$remetente);
self::$documentoTeste1 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);
self::$documentoTeste2 = $this->gerarDadosDocumentoExternoTeste(self::$remetente);

// 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 anexado e incluir documentos relacionados
self::$protocoloTesteAnexado = $this->cadastrarProcesso(self::$processoTesteAnexado);
$this->cadastrarDocumentoExterno(self::$documentoTeste3);
$this->cadastrarDocumentoExterno(self::$documentoTeste4);
self::$documentoTeste3 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);
self::$documentoTeste4 = $this->gerarDadosDocumentoInternoTeste(self::$remetente);

$parametros = [
[
'Descricao' => self::$processoTestePrincipal['DESCRICAO'],
'Interessados' => self::$processoTestePrincipal['INTERESSADOS'],
'Documentos' => [self::$documentoTeste1, self::$documentoTeste2],
],
[
'Descricao' => self::$processoTesteAnexado['DESCRICAO'],
'Interessados' => self::$processoTesteAnexado['INTERESSADOS'],
'Documentos' => [self::$documentoTeste3, self::$documentoTeste4],
]
];

$objProtocoloFixture = new ProtocoloFixture();
$objProtocolosDTO = $objProtocoloFixture->carregarVariados($parametros);

// Cadastrar novo processo de teste principal e incluir documentos relacionados
$this->paginaBase->navegarParaControleProcesso();
self::$protocoloTestePrincipal = $this->cadastrarProcesso(self::$processoTestePrincipal);
$this->cadastrarDocumentoExterno(self::$documentoTeste1);
$i = 0;
foreach($objProtocolosDTO as $objProtocoloDTO) {
$objProcedimentoFixture = new ProcedimentoFixture();

$objProcedimentoDTO = $objProcedimentoFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo()
]);

$objAtividadeFixture = new AtividadeFixture();
$objAtividadeDTO = $objAtividadeFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'Conclusao' => \InfraData::getStrDataHoraAtual(),
'IdTarefa' => \TarefaRN::$TI_GERACAO_PROCEDIMENTO,
'IdUsuarioConclusao' => 100000001
]);

$objContatoFixture = new ContatoFixture();
$objContatoDTO = $objContatoFixture->carregar([
'Nome' => self::$processoTestePrincipal['INTERESSADOS']
]);

$objParticipanteFixture = new ParticipanteFixture();
$objParticipanteDTO = $objParticipanteFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'IdContato' => $objContatoDTO->getNumIdContato()
]);

$objProtocoloAssuntoFixture = new RelProtocoloAssuntoFixture();
$objProtocoloAssuntoFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo()
]);

$objAtributoAndamentoFixture = new AtributoAndamentoFixture();
$objAtributoAndamentoFixture->carregar([
'IdAtividade' => $objAtividadeDTO->getNumIdAtividade()
]);

// Incluir e assinar documentos relacionados
foreach($parametros[$i]['Documentos'] as $documento) {
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'IdProcedimento' => $objProcedimentoDTO->getDblIdProcedimento(),
'Descricao' => $documento['DESCRICAO'],
]);
// Armazenar nome que o arquivo receberá no org destinatário
$docs[$i][] = str_pad($objDocumentoDTO->getDblIdDocumento(), 6, 0, STR_PAD_LEFT).'.html';

$objAssinaturaFixture = new AssinaturaFixture();
$objAssinaturaFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'IdDocumento' => $objDocumentoDTO->getDblIdDocumento(),
]);
}
$protocolo[$i]['formatado'] = $objProtocoloDTO->getStrProtocoloFormatado();
$protocolo[$i]['id'] = $objProtocoloDTO->getDblIdProtocolo();
$i++;
}

// Preencher variaveis que serão usadas posteriormente nos testes
self::$documentoTeste1['ARQUIVO'] = $docs[0][0];
self::$documentoTeste2['ARQUIVO'] = $docs[0][1];
self::$documentoTeste3['ARQUIVO'] = $docs[1][0];
self::$documentoTeste4['ARQUIVO'] = $docs[1][1];
self::$protocoloTestePrincipal = $protocolo[0]['formatado'];
self::$protocoloTestePrincipalId = $protocolo[0]['id'];
self::$protocoloTesteAnexado = $protocolo[1]['formatado'];
self::$protocoloTesteAnexadoId = $protocolo[1]['id'];

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

$this->cadastrarDocumentoExterno(self::$documentoTeste2);
$objAnexoProcessoFixture = new AnexoProcessoFixture();
$objAnexoProcessoFixture->carregar([
'IdProtocolo' => self::$protocoloTestePrincipalId,
'IdDocumento' => self::$protocoloTesteAnexadoId,
]);

// 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(
Expand All @@ -71,9 +154,9 @@ public function test_tramitar_processo_anexado_da_origem()
self::$destinatario['SIGLA_UNIDADE_HIERARQUIA'],
false
);

}


/**
* Teste de verificação do correto envio do processo anexado no sistema remetente
*
Expand Down Expand Up @@ -127,7 +210,6 @@ public function test_verificar_destino_processo_anexado()

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

$strTipoProcesso = utf8_encode("Tipo de processo no órgão de origem: ");
$strTipoProcesso .= self::$processoTestePrincipal['TIPO_PROCESSO'];
$strObservacoes = $orgaosDiferentes ? $strTipoProcesso : null;
Expand All @@ -144,7 +226,7 @@ public function test_verificar_destino_processo_anexado()
$listaDocumentosProcessoPrincipal = $this->paginaProcesso->listarDocumentos();
$this->assertEquals(3, count($listaDocumentosProcessoPrincipal));
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[0], self::$documentoTeste1, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[2], self::$documentoTeste2, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[1], self::$documentoTeste2, self::$destinatario);

$this->paginaProcesso->selecionarDocumento(self::$protocoloTesteAnexado);
$this->assertTrue($this->paginaDocumento->ehProcessoAnexado());
Expand All @@ -157,7 +239,6 @@ public function test_verificar_destino_processo_anexado()
$this->validarDadosDocumento($listaDocumentosProcessoAnexado[1], self::$documentoTeste4, self::$destinatario);
}


/**
* Teste de trâmite externo de processo realizando a devolução para a mesma unidade de origem
*
Expand All @@ -172,18 +253,58 @@ public function test_devolucao_processo_para_origem()
{
self::$remetente = $this->definirContextoTeste(CONTEXTO_ORGAO_B);
self::$destinatario = $this->definirContextoTeste(CONTEXTO_ORGAO_A);

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

// Selecionar banco do org2 para fazer inserção dos documentos
putenv("DATABASE_HOST=org2-database");

// Busca ID que Protocolo principal recebeu no org2
$parametros = [
'ProtocoloFormatado' => self::$protocoloTestePrincipal,
];
$objProtocoloFixture = new ProtocoloFixture();
$objProtocoloDTO = $objProtocoloFixture->buscar($parametros)[0];

//Incluir novos documentos relacionados
$objDocumentoFixture = new DocumentoFixture();
$objDocumentoDTO = $objDocumentoFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'IdProcedimento' => $objProtocoloDTO->getDblIdProtocolo(),
'Descricao' => self::$documentoTeste5['DESCRICAO'],
'StaProtocolo' => \ProtocoloRN::$TP_DOCUMENTO_RECEBIDO,
'StaDocumento' => \DocumentoRN::$TD_EXTERNO,
'IdConjuntoEstilos' => NULL,
]);
//Adicionar anexo ao documento
$objAnexoFixture = new AnexoFixture();
$objAnexoFixture->carregar([
'IdProtocolo' => $objDocumentoDTO->getDblIdDocumento(),
'Nome' => basename(self::$documentoTeste5['ARQUIVO']),
]);

$objDocumentoDTO = $objDocumentoFixture->carregar([
'IdProtocolo' => $objProtocoloDTO->getDblIdProtocolo(),
'IdProcedimento' => $objProtocoloDTO->getDblIdProtocolo(),
'Descricao' => self::$documentoTeste6['DESCRICAO'],
'StaProtocolo' => \ProtocoloRN::$TP_DOCUMENTO_RECEBIDO,
'StaDocumento' => \DocumentoRN::$TD_EXTERNO,
'IdConjuntoEstilos' => NULL,
]);

$objAnexoFixture->carregar([
'IdProtocolo' => $objDocumentoDTO->getDblIdDocumento(),
'Nome' => basename(self::$documentoTeste6['ARQUIVO']),
]);

//Fim das operações no BD do org2
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
$this->abrirProcesso(self::$protocoloTestePrincipal);
$this->cadastrarDocumentoExterno(self::$documentoTeste5);
$this->cadastrarDocumentoExterno(self::$documentoTeste6);

// Trâmitar Externamento processo para órgão/unidade destinatária
$this->tramitarProcessoExternamente(
Expand All @@ -209,6 +330,7 @@ public function test_devolucao_processo_para_origem()
public function test_verificar_devolucao_origem_processo_anexado()
{
$orgaosDiferentes = self::$remetente['URL'] != self::$destinatario['URL'];

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

Expand Down Expand Up @@ -243,10 +365,8 @@ public function test_verificar_devolucao_origem_processo_anexado()
public function test_verificar_devolucao_destino_processo_anexado()
{
$strProtocoloTeste = self::$protocoloTestePrincipal;
$orgaosDiferentes = self::$remetente['URL'] != self::$destinatario['URL'];

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

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

$this->validarDadosProcesso(
Expand All @@ -262,7 +382,7 @@ public function test_verificar_devolucao_destino_processo_anexado()
$listaDocumentosProcessoPrincipal = $this->paginaProcesso->listarDocumentos();
$this->assertEquals(5, count($listaDocumentosProcessoPrincipal));
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[0], self::$documentoTeste1, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[2], self::$documentoTeste2, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[1], self::$documentoTeste2, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[3], self::$documentoTeste5, self::$destinatario);
$this->validarDadosDocumento($listaDocumentosProcessoPrincipal[4], self::$documentoTeste6, self::$destinatario);

Expand Down
Loading

0 comments on commit d1800ad

Please sign in to comment.