get('/up')->assertOk(); } public function test_up_fails_when_the_database_is_unreachable(): void { DB::shouldReceive('connection')->andThrow(new RuntimeException('getaddrinfo for db failed')); $this->get('/up')->assertServerError(); } public function test_the_listener_throws_when_the_connection_fails(): void { DB::shouldReceive('connection')->andThrow(new RuntimeException('getaddrinfo for db failed')); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('The database is not reachable'); app(VerifyDatabaseIsReachable::class)->handle(new DiagnosingHealth); } public function test_the_listener_passes_when_the_connection_works(): void { app(VerifyDatabaseIsReachable::class)->handle(new DiagnosingHealth); $this->addToAssertionCount(1); } }