-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: adicionar tests funcionais e testes de carga
- Loading branch information
1 parent
81b8c43
commit 5e5f195
Showing
11 changed files
with
446 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests_super/funcional/src/fixtures/AnexoProcessoFixture.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
class AnexoProcessoFixture extends FixtureBase | ||
{ | ||
protected $objAssinaturaDTO; | ||
|
||
protected function inicializarObjInfraIBanco() | ||
{ | ||
return \BancoSEI::getInstance(); | ||
} | ||
|
||
protected function cadastrar($dados = []) | ||
{ | ||
$objAtividadeFixture = new AtividadeFixture(); | ||
$objAtividadeFixture->cadastrar( | ||
[ | ||
'IdProtocolo' => $dados['IdProtocolo'], | ||
'IdTarefa' => \TarefaRN::$TI_ANEXADO_PROCESSO,//101 | ||
] | ||
); | ||
$objAtividadeFixture->cadastrar( | ||
[ | ||
'IdProtocolo' => $dados['IdDocumento'], | ||
'IdTarefa' => \TarefaRN::$TI_ANEXADO_AO_PROCESSO,//102 | ||
'IdUsuarioConclusao' => $dados['IdUsuarioConclusao'] ?: 100000001, | ||
'Conclusao' => InfraData::getStrDataHoraAtual(), | ||
|
||
] | ||
); | ||
$objAtividadeFixture->cadastrar( | ||
[ | ||
'IdProtocolo' => $dados['IdDocumento'], | ||
'IdTarefa' => \TarefaRN::$TI_CONCLUSAO_AUTOMATICA_UNIDADE,//41 | ||
'IdUsuarioConclusao' => $dados['IdUsuarioConclusao'] ?: 100000001, | ||
'Conclusao' => InfraData::getStrDataHoraAtual(), | ||
] | ||
); | ||
|
||
$parametros = [ | ||
'IdProtocolo' => $dados['IdProtocolo'], // idprotocolo1 | ||
'IdDocumento' => $dados['IdDocumento'], // idprotocolo2 | ||
'Associacao' => 2, | ||
]; | ||
$objRelProtocoloProtocoloFixture = new RelProtocoloProtocoloFixture(); | ||
$objRelProtocoloProtocoloFixtureDTO = $objRelProtocoloProtocoloFixture->carregar($parametros); | ||
return $objRelProtocoloProtocoloFixtureDTO; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
class AnexoFixture extends FixtureBase | ||
{ | ||
protected $objAnexoDTO; | ||
|
||
protected function inicializarObjInfraIBanco() | ||
{ | ||
return \BancoSEI::getInstance(); | ||
} | ||
|
||
protected function cadastrar($dados = []) | ||
{ | ||
$dados['Nome'] = $dados['Nome'] ?: 'arquivo_pequeno_A.pdf'; | ||
|
||
$objAnexoDTO = new \AnexoDTO(); | ||
$objAnexoDTO->setNumIdUnidade($dados['IdUnidade'] ?: '110000001'); | ||
$objAnexoDTO->setDblIdProtocolo($dados['IdProtocolo']); | ||
$objAnexoDTO->setNumTamanho($dados['Tamanho'] ?: 16); | ||
$objAnexoDTO->setNumIdBaseConhecimento($dados['IdBaseConhecimento'] ?: null); | ||
$objAnexoDTO->setStrNome($dados['Nome']); | ||
$objAnexoDTO->setDthInclusao($dados['Inclusao'] ?: \InfraData::getStrDataHoraAtual()); | ||
$objAnexoDTO->setNumIdUsuario($dados['IdUsuario'] ?: 100000001); | ||
$objAnexoDTO->setStrSinAtivo($dados['SinAtivo'] ?: 'S'); | ||
$objAnexoDTO->setStrHash($dados['Hash'] ?: 'e307098a01b40de6183583f3163ac6ed'); | ||
|
||
$objAnexoBD = new \AnexoBD(\BancoSEI::getInstance()); | ||
$objAnexoDTO = $objAnexoBD->cadastrar($objAnexoDTO); | ||
$this->realizarUpload($dados['Nome'],$objAnexoDTO->getNumIdAnexo()); | ||
|
||
return $objAnexoDTO; | ||
} | ||
|
||
public function realizarUpload($caminhoOrigem, $nomeDestino) | ||
{ | ||
|
||
// Obtém a orgão atual | ||
$org = getenv('DATABASE_HOST'); | ||
|
||
// Obtém a data atual | ||
$dataAtual = date('Y/m/d'); | ||
|
||
// Define os caminhos de destino baseado na data atual e no orgão que será feito o upload | ||
$caminhoDestinoBase = "/var/sei/arquivos/{$org}/{$dataAtual}/"; | ||
$caminhoOrigemBase = '/tmp/'; | ||
|
||
// Cria o diretório de destino se não existir | ||
if (!file_exists($caminhoDestinoBase)) { | ||
mkdir($caminhoDestinoBase, 0777, true); // Cria diretórios recursivamente com permissão 0777 | ||
} | ||
|
||
// Cria o caminho completo de destino | ||
$caminhoDestinoCompleto = $caminhoDestinoBase.$nomeDestino; | ||
|
||
// Cria o caminho completo de origem | ||
$caminhoOrigemCompleto = $caminhoOrigemBase.$caminhoOrigem; | ||
|
||
try { | ||
// Verifica se o arquivo de origem existe | ||
if (!file_exists($caminhoOrigemCompleto)) { | ||
throw new \Exception("O arquivo de origem não existe.\nArquivo=".$caminhoOrigemCompleto); | ||
} | ||
|
||
// Copia o arquivo para o destino | ||
if (!copy($caminhoOrigemCompleto, $caminhoDestinoCompleto)) { | ||
throw new \Exception("Falha ao copiar o arquivo para o destino.\nArquivo=".$caminhoOrigemCompleto."\nDestino=".$caminhoDestinoCompleto); | ||
} | ||
|
||
} catch (\Exception $e) { | ||
echo "\nErro: " . $e->getMessage(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
class ContatoFixture extends FixtureBase | ||
{ | ||
protected $objContatoDTO; | ||
|
||
public function __construct() | ||
{ | ||
$this->objContatoDTO = new \ContatoDTO(); | ||
} | ||
|
||
protected function inicializarObjInfraIBanco() | ||
{ | ||
return \BancoSEI::getInstance(); | ||
} | ||
|
||
protected function cadastrar($dados = []) | ||
{ | ||
|
||
$dados['IdContato'] = $this->getObjInfraIBanco()->getValorSequencia('seq_contato'); | ||
$dados['Nome'] = $dados['Nome'] ?: 'teste'; | ||
|
||
$this->objContatoDTO->setNumIdContato($dados['IdContato']); | ||
$this->objContatoDTO->setNumIdContatoAssociado($dados['IdContatoAssociado'] ?: $dados['IdContato']); | ||
$this->objContatoDTO->setStrNome($dados['Nome']); | ||
$this->objContatoDTO->setStrNomeRegistroCivil($dados['NomeRegistroCivil'] ?: $dados['Nome']); | ||
// $this->objContatoDTO->setNumIdCargo($dados['IdCargo'] ?: 0); | ||
// $this->objContatoDTO->setNumIdCategoria($dados['IdCategoria'] ?: 110000001); | ||
$this->objContatoDTO->setStrSinAtivo($dados['SinAtivo'] ?: 'S'); | ||
$this->objContatoDTO->setStrIdxContato($dados['IdxContato'] ?: strtolower($dados['Nome'])); | ||
$this->objContatoDTO->setNumIdUnidadeCadastro($dados['IdUnidadeCadastro'] ?: 110000001); | ||
$this->objContatoDTO->setNumIdUsuarioCadastro($dados['IdUsuarioCadastro'] ?: 100000001); | ||
$this->objContatoDTO->setDthCadastro($dados['Cadastro'] ?: \InfraData::getStrDataHoraAtual()); | ||
$this->objContatoDTO->setNumIdTipoContato($dados['IdTipoContato'] ?: 4); | ||
$this->objContatoDTO->setStrStaNatureza($dados['StaNatureza'] ?: 'F'); | ||
$this->objContatoDTO->setStrSinEnderecoAssociado($dados['SinEnderecoAssociado'] ?: 'N'); | ||
|
||
$objContatoBD = new \ContatoBD(\BancoSEI::getInstance()); | ||
$objContatoBD->cadastrar($this->objContatoDTO); | ||
|
||
return $this->objContatoDTO; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.