diff --git a/tests/Exception/AbstractHttpExceptionTest.php b/tests/Exception/AbstractHttpExceptionTest.php new file mode 100644 index 0000000..925cfe7 --- /dev/null +++ b/tests/Exception/AbstractHttpExceptionTest.php @@ -0,0 +1,22 @@ +getMockForAbstractClass(AbstractHttpException::class, [ + $response, 404 + ]); + $originalMessage = $exception->getOriginalMessage(); + $this->assertEquals('Not Found', $originalMessage->name); + } +} diff --git a/tests/Service/V1/IbgeServiceTest.php b/tests/Service/V1/IbgeServiceTest.php index 7ac8abf..ec99818 100644 --- a/tests/Service/V1/IbgeServiceTest.php +++ b/tests/Service/V1/IbgeServiceTest.php @@ -35,6 +35,19 @@ public function testGetCitiesByStateNotFound(): void $ibgeService->getCitiesByState('invalid'); } + public function testGetAllStates(): void + { + $data = loadFixture('Entity/V1/Ibge/states'); + $mock = new MockHandler([ + new Response(200, [], strval(json_encode($data))), + ]); + $handlerStack = HandlerStack::create($mock); + $ibgeService = new IbgeService(new Adapter(new Client(['handler' => $handlerStack]))); + + $states = $ibgeService->getAllStates(); + $this->assertInstanceOf(State::class, $states[0]); + } + public function testGetState(): void { $data = loadFixture('Entity/V1/Ibge/states');