Skip to content

Commit

Permalink
feat: adicionar code coverage para o teste unitário
Browse files Browse the repository at this point in the history
  • Loading branch information
Glaydson Rodrigues committed Nov 27, 2024
1 parent bc1626f commit 529d962
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ test-parallel-otimizado: .env $(FILE_VENDOR_FUNCIONAL) up
make -j2 test-functional-parallel tramitar-pendencias-silent


test-unit: $(FILE_VENDOR_UNITARIO)
$(CMD_DOCKER_COMPOSE) -f $(PEN_TEST_FUNC)/docker-compose.yml run --rm -w /tests php-test-unit bash -c 'vendor/bin/phpunit rn/$(addsuffix .php,$(teste))'
test-unit: .env $(FILE_VENDOR_UNITARIO)
$(CMD_DOCKER_COMPOSE) -f $(PEN_TEST_FUNC)/docker-compose.yml run --rm -w /tests php-test-unit bash -c 'XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html html rn/$(addsuffix .php,$(teste))'

test: test-unit test-functional

Expand Down
34 changes: 2 additions & 32 deletions src/rn/ProcessoEletronicoRN.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
$dirSeiVendor = !defined("DIR_SEI_VENDOR") ? getenv("DIR_SEI_VENDOR") ?: __DIR__ . "/../vendor" : DIR_SEI_VENDOR;
require_once $dirSeiVendor . '/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
Expand Down Expand Up @@ -1699,37 +1700,6 @@ public function receberComponenteDigital($parNumIdentificacaoTramite, $parStrHas
}
}

public function receberComponenteDigitalS($parNumIdentificacaoTramite, $parStrHashComponenteDigital, $parStrProtocolo, $parObjParteComponente = null)
{
$endpoint = "tramites/{$parNumIdentificacaoTramite}/protocolos/componentes-digitais";
try {
$identificacaoDoComponenteDigital = [
'hashDoComponenteDigital' => $parStrHashComponenteDigital,
'protocolo' => $parStrProtocolo,
];

// Se for passado o parametro $parObjParteComponente retorna apenas parte especifica do componente digital
if (!is_null($parObjParteComponente)) {
$parte = $parObjParteComponente->inicio . '-' . $parObjParteComponente->fim;
$endpoint = "tramites/{$parNumIdentificacaoTramite}/protocolos/componentes-digitais/partes/{$parte}";
}

$strComponenteDigitalBase64 = $this->post($endpoint, $identificacaoDoComponenteDigital);

$objResultado = new stdClass();
$objResultado->conteudoDoComponenteDigital = new stdClass();
$objResultado->conteudoDoComponenteDigital = base64_decode($strComponenteDigitalBase64);

return $objResultado;

} catch (\Exception $e) {
$mensagem = "Falha no recebimento do componente digital";
$detalhes = InfraString::formatarJavaScript($this->tratarFalhaWebService($e));
throw new InfraException($mensagem, $e, $detalhes);
}
}


public function consultarTramites($parNumIdTramite = null, $parNumeroRegistro = null, $parNumeroUnidadeRemetente = null, $parNumeroUnidadeDestino = null, $parProtocolo = null, $parNumeroRepositorioEstruturas = null)
{
$endpoint = 'tramites';
Expand Down
4 changes: 3 additions & 1 deletion tests_super/unitario/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

//require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

define("DIR_SEI_VENDOR", __DIR__ . '/vendor');

// define('DIR_SEI_WEB', realpath(DIR_SEI_CONFIG . '/../web'));

Expand Down
4 changes: 3 additions & 1 deletion tests_super/unitario/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"require-dev": {
"phpunit/phpunit": "9.*",
"phpunit/php-code-coverage": "*",
"phpunit/phpunit-selenium": "dev-master"
"phpunit/phpunit-selenium": "dev-master",
"guzzlehttp/guzzle": "^7.0"
}
}


9 changes: 9 additions & 0 deletions tests_super/unitario/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
<!-- Localização do diretório onde está contido os arquivos de configuração do SEI -->
<const name="DIR_SEI_CONFIG" value="/opt/sei/config"/>
</php>
<coverage>
<exclude>
<directory suffix=".php">/opt/sei/web/modulos/pen/vendor</directory>
<directory suffix=".php">/opt/sei/web/modulos/pen/config</directory>
</exclude>
<include>
<directory suffix=".php">/opt/sei/web/modulos/pen</directory>
</include>
</coverage>
</phpunit>

0 comments on commit 529d962

Please sign in to comment.