diff --git a/tests_sei4/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php b/tests_sei4/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php new file mode 100644 index 00000000..8d50e206 --- /dev/null +++ b/tests_sei4/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php @@ -0,0 +1,73 @@ +mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) + ->onlyMethods(['get']) + ->getMock(); + } + + public function testBuscarEstruturaSucesso() + { + $mockResponse = [ + "numeroDeIdentificacaoDaEstrutura" => "157406", + "nome" => "CGPRO_PAUL_ORG1", + "sigla" => "CGPRO_PAUL_ORG1", + "ativo" => true, + "unidadeProtocolizadora" => false, + "unidadeReceptora" => false, + "aptoParaReceberTramites" => true, + "codigoNoOrgaoEntidade" => "", + "codigoUnidadeReceptora" => null, + "codigoUnidadeProtocolizadora" => null, + "tipoDeTramitacao" => 1, + "hierarquia" => [] + ]; + + // Configura o mock para retornar a resposta + $this->mockService->expects($this->once()) + ->method('get') + ->willReturn($mockResponse); + + $resultado = $this->mockService->buscarEstrutura(5, 157406); + + $this->assertInstanceOf(EstruturaDTO::class, $resultado, 'O retorno deve ser uma instância da classe EstruturaDTO.'); + } + + public function testBuscarEstruturaLancaExcecao() + { + $this->mockService->expects($this->once()) + ->method('get') + ->willThrowException(new Exception()); + + $this->expectException(InfraException::class); + $this->expectExceptionMessage('Falha na obtenção de unidades externas'); + + $this->mockService->consultarEstrutura(159098, 152254, false); + } +} diff --git a/tests_sei41/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php b/tests_sei41/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php new file mode 100644 index 00000000..8d50e206 --- /dev/null +++ b/tests_sei41/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php @@ -0,0 +1,73 @@ +mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) + ->onlyMethods(['get']) + ->getMock(); + } + + public function testBuscarEstruturaSucesso() + { + $mockResponse = [ + "numeroDeIdentificacaoDaEstrutura" => "157406", + "nome" => "CGPRO_PAUL_ORG1", + "sigla" => "CGPRO_PAUL_ORG1", + "ativo" => true, + "unidadeProtocolizadora" => false, + "unidadeReceptora" => false, + "aptoParaReceberTramites" => true, + "codigoNoOrgaoEntidade" => "", + "codigoUnidadeReceptora" => null, + "codigoUnidadeProtocolizadora" => null, + "tipoDeTramitacao" => 1, + "hierarquia" => [] + ]; + + // Configura o mock para retornar a resposta + $this->mockService->expects($this->once()) + ->method('get') + ->willReturn($mockResponse); + + $resultado = $this->mockService->buscarEstrutura(5, 157406); + + $this->assertInstanceOf(EstruturaDTO::class, $resultado, 'O retorno deve ser uma instância da classe EstruturaDTO.'); + } + + public function testBuscarEstruturaLancaExcecao() + { + $this->mockService->expects($this->once()) + ->method('get') + ->willThrowException(new Exception()); + + $this->expectException(InfraException::class); + $this->expectExceptionMessage('Falha na obtenção de unidades externas'); + + $this->mockService->consultarEstrutura(159098, 152254, false); + } +} diff --git a/tests_super/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php b/tests_super/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php new file mode 100644 index 00000000..8d50e206 --- /dev/null +++ b/tests_super/unitario/rn/ProcessoEletronicoRN/BuscarEstruturaTest.php @@ -0,0 +1,73 @@ +mockService = $this->getMockBuilder(ProcessoEletronicoRN::class) + ->onlyMethods(['get']) + ->getMock(); + } + + public function testBuscarEstruturaSucesso() + { + $mockResponse = [ + "numeroDeIdentificacaoDaEstrutura" => "157406", + "nome" => "CGPRO_PAUL_ORG1", + "sigla" => "CGPRO_PAUL_ORG1", + "ativo" => true, + "unidadeProtocolizadora" => false, + "unidadeReceptora" => false, + "aptoParaReceberTramites" => true, + "codigoNoOrgaoEntidade" => "", + "codigoUnidadeReceptora" => null, + "codigoUnidadeProtocolizadora" => null, + "tipoDeTramitacao" => 1, + "hierarquia" => [] + ]; + + // Configura o mock para retornar a resposta + $this->mockService->expects($this->once()) + ->method('get') + ->willReturn($mockResponse); + + $resultado = $this->mockService->buscarEstrutura(5, 157406); + + $this->assertInstanceOf(EstruturaDTO::class, $resultado, 'O retorno deve ser uma instância da classe EstruturaDTO.'); + } + + public function testBuscarEstruturaLancaExcecao() + { + $this->mockService->expects($this->once()) + ->method('get') + ->willThrowException(new Exception()); + + $this->expectException(InfraException::class); + $this->expectExceptionMessage('Falha na obtenção de unidades externas'); + + $this->mockService->consultarEstrutura(159098, 152254, false); + } +}