summaryrefslogtreecommitdiffstats
path: root/tests/HealthTest.php
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 14:58:55 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 14:58:55 -0300
commit64764fb9fac0227f8e0443e7c7519d73aec275b9 (patch)
treecb4fc56eeb6ecce53854f9c530609cf01ab3349f /tests/HealthTest.php
downloadphp-1fd1470890518a68130b3b9058fe1bebddca9f07.tar.gz
Initial importv0.1.0
Diffstat (limited to 'tests/HealthTest.php')
-rw-r--r--tests/HealthTest.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/HealthTest.php b/tests/HealthTest.php
new file mode 100644
index 0000000..08c047b
--- /dev/null
+++ b/tests/HealthTest.php
@@ -0,0 +1,41 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Cepis\Tests;
+
+final class HealthTest extends ServerTestCase
+{
+ public function testReadsHealth(): void
+ {
+ $this->server->respond('/health', [self::json([
+ 'status' => 'ok',
+ 'dne' => '26071',
+ 'ceps' => 1596168,
+ 'geo' => 894489,
+ 'base_gerada_em' => '2026-07-24T03:48:28Z',
+ ])]);
+
+ $health = $this->client->health();
+
+ self::assertTrue($health->isOk());
+ self::assertSame('26071', $health->dne);
+ self::assertSame(1596168, $health->ceps);
+ self::assertSame(894489, $health->geo);
+ self::assertSame('2026-07-24T03:48:28Z', $health->base_gerada_em);
+ }
+
+ public function testDegradedDoesNotThrow(): void
+ {
+ $this->server->respond('/health', [self::json(
+ ['status' => 'degradado', 'dne' => '', 'ceps' => 0, 'geo' => 0],
+ 503,
+ )]);
+
+ $health = $this->client->health();
+
+ self::assertFalse($health->isOk());
+ self::assertSame('degradado', $health->status);
+ self::assertSame(1, $this->server->countCalls('/health'));
+ }
+}