From d1800ad16e54715c49b19fe3ed911d8eb812cc7d Mon Sep 17 00:00:00 2001 From: Marcus Dias Date: Mon, 25 Mar 2024 14:23:09 -0300 Subject: [PATCH] test: refatorar TramiteProcessoAnexoComDevolucaoTeste TramiteProcessoAnexadoTest com rebase para release 3.6.0 --- ...TramiteProcessoAnexadoComDevolucaoTest.php | 184 +++++++++++++++--- .../tests/TramiteProcessoAnexadoTest.php | 131 ++++++++++--- ...TramiteProcessoAnexadoComDevolucaoTest.php | 184 +++++++++++++++--- .../tests/TramiteProcessoAnexadoTest.php | 131 ++++++++++--- 4 files changed, 518 insertions(+), 112 deletions(-) diff --git a/tests_sei4/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php b/tests_sei4/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php index e9604e732..9d0fcd1e1 100755 --- a/tests_sei4/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php +++ b/tests_sei4/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php @@ -1,5 +1,7 @@ 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( @@ -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 * @@ -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; @@ -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()); @@ -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 * @@ -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( @@ -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); @@ -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( @@ -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); diff --git a/tests_sei4/funcional/tests/TramiteProcessoAnexadoTest.php b/tests_sei4/funcional/tests/TramiteProcessoAnexadoTest.php index 5ebaa1cfc..3e72143cf 100755 --- a/tests_sei4/funcional/tests/TramiteProcessoAnexadoTest.php +++ b/tests_sei4/funcional/tests/TramiteProcessoAnexadoTest.php @@ -1,5 +1,7 @@ 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( @@ -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 * @@ -109,7 +192,7 @@ public function test_verificar_origem_processo_anexado() $this->validarHistoricoTramite(self::$destinatario['NOME_UNIDADE'], true, true); $this->validarProcessosTramitados(self::$protocoloTestePrincipal, $orgaosDiferentes); } - + /** * Teste de verificação do correto recebimento do processo anexado no destinatário * @@ -143,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()); diff --git a/tests_super/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php b/tests_super/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php index e9604e732..9d0fcd1e1 100755 --- a/tests_super/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php +++ b/tests_super/funcional/tests/TramiteProcessoAnexadoComDevolucaoTest.php @@ -1,5 +1,7 @@ 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( @@ -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 * @@ -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; @@ -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()); @@ -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 * @@ -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( @@ -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); @@ -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( @@ -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); diff --git a/tests_super/funcional/tests/TramiteProcessoAnexadoTest.php b/tests_super/funcional/tests/TramiteProcessoAnexadoTest.php index 5ebaa1cfc..3e72143cf 100755 --- a/tests_super/funcional/tests/TramiteProcessoAnexadoTest.php +++ b/tests_super/funcional/tests/TramiteProcessoAnexadoTest.php @@ -1,5 +1,7 @@ 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( @@ -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 * @@ -109,7 +192,7 @@ public function test_verificar_origem_processo_anexado() $this->validarHistoricoTramite(self::$destinatario['NOME_UNIDADE'], true, true); $this->validarProcessosTramitados(self::$protocoloTestePrincipal, $orgaosDiferentes); } - + /** * Teste de verificação do correto recebimento do processo anexado no destinatário * @@ -143,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());