-
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.
- teste unitarios de consulta estrutura, - teste unitário de consta estruturas, - reestruturacao de testes iniciais existentes, - correção de bug no docker-compose.yml de encoding, - inclusão de testdox para visualização de error e tempo de testes
- Loading branch information
Showing
23 changed files
with
1,144 additions
and
332 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<?php | ||
|
||
//require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
// define('DIR_SEI_WEB', realpath(DIR_SEI_CONFIG . '/../web')); | ||
|
||
// set_include_path('.:/php/includes:'.realpath(DIR_SEI_CONFIG . '/../../infra/infra_php')); | ||
// require_once DIR_SEI_WEB . '/SEI.php'; | ||
//require_once __DIR__ . '/assets/config/ConfiguracaoModPEN.php'; | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
define("DIR_SEI_VENDOR", __DIR__ . '/vendor'); |
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
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,17 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class CompararVersoesTest extends TestCase | ||
{ | ||
public function testCompararVersoes() | ||
{ | ||
$this->assertTrue(InfraUtil::compararVersoes("0.0.1", "<", "0.0.2")); | ||
$this->assertTrue(InfraUtil::compararVersoes("0.1.0", "<", "0.2.0")); | ||
$this->assertTrue(InfraUtil::compararVersoes("1.0.0", "<", "2.0.0")); | ||
$this->assertTrue(InfraUtil::compararVersoes("4.0.3", "==", "4.0.3.0")); | ||
$this->assertTrue(InfraUtil::compararVersoes("4.0.3", "<", "4.0.3.1")); | ||
$this->assertTrue(InfraUtil::compararVersoes("4.0.4", ">", "4.0.3.0")); | ||
$this->assertTrue(InfraUtil::compararVersoes("4.0.3.0", "==", "4.0.3.5", 3, true)); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
tests_sei4/unitario/rn/ProcessoEletronicoRN/ConsultarEstruturaTest.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,108 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Classe de teste para o método listarRepositoriosDeEstruturas da classe ProcessoEletronicoRN. | ||
* | ||
* Esta classe utiliza PHPUnit para verificar o comportamento do método listarRepositoriosDeEstruturas | ||
* em diferentes cenários, garantindo que ele funcione conforme o esperado. | ||
*/ | ||
class ConsultarEstruturaTest extends TestCase | ||
{ | ||
/** | ||
* Mock da classe ProcessoEletronicoRN. | ||
* | ||
* @var ProcessoEletronicoRN|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $mockService; | ||
|
||
/** | ||
* Configuração inicial do teste. | ||
* | ||
* Este método cria um mock da classe ProcessoEletronicoRN e redefine | ||
* o método 'get' para simular comportamentos durante os testes. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) | ||
->onlyMethods(['get']) | ||
->getMock(); | ||
} | ||
|
||
public function testConsultarEstruturaListaSucesso() | ||
{ | ||
$mockResponse = [ | ||
"numeroDeIdentificacaoDaEstrutura" => "159098", | ||
"nome" => "Mauro ORG1 Filha", | ||
"sigla" => "Mauro ORG1 Filha", | ||
"ativo" => true, | ||
"unidadeReceptora" => false, | ||
"aptoParaReceberTramites" => true, | ||
"codigoNoOrgaoEntidade" => "", | ||
"codigoUnidadeReceptora" => "", | ||
"tipoDeTramitacao" => 0, | ||
"hierarquia" => [ | ||
[ | ||
"numeroDeIdentificacaoDaEstrutura" => "152254", | ||
"nome" => "Órgão de Desenvolvimento ABC (FIRST) - ORGABC", | ||
"sigla" => "ORGABC" | ||
] | ||
] | ||
]; | ||
|
||
// Configura o mock para retornar a resposta | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willReturn($mockResponse); | ||
|
||
$resultado = $this->mockService->consultarEstrutura(159098, 152254, false); | ||
|
||
$this->assertInstanceOf(EstruturaDTO::class, $resultado, 'O retorno deve ser uma instância da classe EstruturaDTO.'); | ||
} | ||
|
||
public function testConsultarEstruturaListaBolRetornoRawTrueSucesso() | ||
{ | ||
$mockResponse = [ | ||
"numeroDeIdentificacaoDaEstrutura" => "159098", | ||
"nome" => "Mauro ORG1 Filha", | ||
"sigla" => "Mauro ORG1 Filha", | ||
"ativo" => true, | ||
"unidadeReceptora" => false, | ||
"aptoParaReceberTramites" => true, | ||
"codigoNoOrgaoEntidade" => "", | ||
"codigoUnidadeReceptora" => "", | ||
"tipoDeTramitacao" => 0, | ||
"hierarquia" => [ | ||
[ | ||
"numeroDeIdentificacaoDaEstrutura" => "152254", | ||
"nome" => "Órgão de Desenvolvimento ABC (FIRST) - ORGABC", | ||
"sigla" => "ORGABC" | ||
] | ||
] | ||
]; | ||
|
||
// Configura o mock para retornar a resposta | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willReturn($mockResponse); | ||
|
||
$resultado = $this->mockService->consultarEstrutura(159098, 152254, true); | ||
|
||
$this->assertInstanceOf(stdClass::class, $resultado, 'O retorno deve ser uma instância da classe EstruturaDTO.'); | ||
} | ||
|
||
public function testConsultarEstruturaListaLancaExcecao() | ||
{ | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willThrowException(new Exception('Erro na requisição')); | ||
|
||
$this->expectException(InfraException::class); | ||
$this->expectExceptionMessage('Falha na obtenção de unidades externas'); | ||
|
||
$this->mockService->consultarEstrutura(159098, 152254, false); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
tests_sei4/unitario/rn/ProcessoEletronicoRN/ConsultarEstruturasTest.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,82 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Classe de teste para o método listarRepositoriosDeEstruturas da classe ProcessoEletronicoRN. | ||
* | ||
* Esta classe utiliza PHPUnit para verificar o comportamento do método listarRepositoriosDeEstruturas | ||
* em diferentes cenários, garantindo que ele funcione conforme o esperado. | ||
*/ | ||
class ConsultarEstruturasTest extends TestCase | ||
{ | ||
/** | ||
* Mock da classe ProcessoEletronicoRN. | ||
* | ||
* @var ProcessoEletronicoRN|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $mockService; | ||
|
||
/** | ||
* Configuração inicial do teste. | ||
* | ||
* Este método cria um mock da classe ProcessoEletronicoRN e redefine | ||
* o método 'get' para simular comportamentos durante os testes. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) | ||
->onlyMethods(['get']) | ||
->getMock(); | ||
} | ||
|
||
public function testConsultarEstruturaListaSucesso() | ||
{ | ||
$mockResponse = [ | ||
"estruturas" => [ | ||
[ | ||
"numeroDeIdentificacaoDaEstrutura" => "159098", | ||
"nome" => "Mauro ORG1 Filha", | ||
"sigla" => "Mauro ORG1 Filha", | ||
"ativo" => true, | ||
"unidadeReceptora" => false, | ||
"aptoParaReceberTramites" => true, | ||
"codigoNoOrgaoEntidade" => "", | ||
"codigoUnidadeReceptora" => "", | ||
"tipoDeTramitacao" => 0, | ||
"hierarquia" => [ | ||
[ | ||
"numeroDeIdentificacaoDaEstrutura" => "152254", | ||
"nome" => "Órgão de Desenvolvimento ABC (FIRST) - ORGABC", | ||
"sigla" => "ORGABC" | ||
] | ||
] | ||
] | ||
], | ||
"totalDeRegistros" => 1 | ||
]; | ||
|
||
// Configura o mock para retornar a resposta | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willReturn($mockResponse); | ||
|
||
$resultado = $this->mockService->consultarEstruturas(159098, []); | ||
|
||
$this->assertIsArray($resultado, 'O retorno deve ser um array.'); | ||
} | ||
|
||
public function testConsultarEstruturaListaLancaExcecao() | ||
{ | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willThrowException(new Exception('Erro na requisição')); | ||
|
||
$this->expectException(InfraException::class); | ||
$this->expectExceptionMessage('Falha na obtenção de unidades externas'); | ||
|
||
$this->mockService->consultarEstruturas(159098, []); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
tests_sei4/unitario/rn/ProcessoEletronicoRN/ListarRepositorioTest.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,97 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Classe de teste para o método listarRepositoriosDeEstruturas da classe ProcessoEletronicoRN. | ||
* | ||
* Esta classe utiliza PHPUnit para verificar o comportamento do método listarRepositoriosDeEstruturas | ||
* em diferentes cenários, garantindo que ele funcione conforme o esperado. | ||
*/ | ||
class ListarRepositorioTest extends TestCase | ||
{ | ||
/** | ||
* Mock da classe ProcessoEletronicoRN. | ||
* | ||
* @var ProcessoEletronicoRN|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $mockService; | ||
|
||
/** | ||
* Configuração inicial do teste. | ||
* | ||
* Este método cria um mock da classe ProcessoEletronicoRN e redefine | ||
* o método 'get' para simular comportamentos durante os testes. | ||
* | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) | ||
->onlyMethods(['get']) | ||
->getMock(); | ||
} | ||
|
||
/** | ||
* Testa o método listarRepositoriosDeEstruturas para garantir que ele | ||
* retorna uma lista de repositórios de estruturas com sucesso. | ||
* | ||
* Cenário testado: | ||
* - O método 'get' retorna uma lista simulada de repositórios. | ||
* - O retorno do método deve ser um array contendo objetos do tipo RepositorioDTO. | ||
* | ||
* Asserções: | ||
* - O retorno deve ser um array. | ||
* - A quantidade de itens no retorno deve ser igual à quantidade simulada. | ||
* - O primeiro item do retorno deve ser uma instância de RepositorioDTO. | ||
* | ||
* @return void | ||
*/ | ||
public function testListarRepositoriosDeEstruturasRetornaListaSucesso() | ||
{ | ||
$mockResponse = [ | ||
["id" => 49, "nome" => "Acre - AC", "ativo" => true], | ||
["id" => 2, "nome" => "Advocacia-Geral da União", "ativo" => true], | ||
["id" => 7, "nome" => "Alagoas( Estado)", "ativo" => true], | ||
["id" => 20, "nome" => "Banco Central do Brasil 2", "ativo" => true], | ||
]; | ||
|
||
// Configura o mock para retornar a resposta | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willReturn($mockResponse); | ||
|
||
$resultado = $this->mockService->listarRepositoriosDeEstruturas(); | ||
|
||
$this->assertIsArray($resultado, 'O retorno deve ser um array.'); | ||
$this->assertCount(count($mockResponse), $resultado, 'A quantidade de objetos no retorno está incorreta.'); | ||
$this->assertInstanceOf(RepositorioDTO::class, $resultado[0], 'O primeiro objeto na lista deve ser uma instância da classe RepositorioDTO.'); | ||
} | ||
|
||
/** | ||
* Testa o método listarRepositoriosDeEstruturas para garantir que ele lança | ||
* uma exceção quando a requisição falha. | ||
* | ||
* Cenário testado: | ||
* - O método 'get' lança uma exceção simulada. | ||
* - O método listarRepositoriosDeEstruturas deve capturar a exceção e | ||
* relançar uma InfraException com a mensagem apropriada. | ||
* | ||
* Asserções: | ||
* - Uma exceção do tipo InfraException deve ser lançada. | ||
* - A mensagem da exceção deve ser "Falha na obtenção dos Repositórios de Estruturas Organizacionais". | ||
* | ||
* @return void | ||
*/ | ||
public function testListarRepositoriosDeEstruturasLancaExcecao() | ||
{ | ||
$this->mockService->expects($this->once()) | ||
->method('get') | ||
->willThrowException(new Exception('Erro na requisição')); | ||
|
||
$this->expectException(InfraException::class); | ||
$this->expectExceptionMessage('Falha na obtenção dos Repositórios de Estruturas Organizacionais'); | ||
|
||
$this->mockService->listarRepositoriosDeEstruturas(); | ||
} | ||
} |
Oops, something went wrong.