Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 9ec9e27

Browse files
author
Robert Kummer
committed
health check api route documented and tested
1 parent 1511af5 commit 9ec9e27

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

app/Http/Controllers/Api/HealthController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Http\Controllers\Api;
44

5+
use Illuminate\Http\JsonResponse;
6+
57
class HealthController extends ApiController
68
{
79
public function health()
@@ -13,7 +15,14 @@ public function health()
1315
return $this->respond(200, 'healthy');
1416
}
1517

16-
private function respond($code, $message)
18+
/**
19+
* responds given data as json
20+
*
21+
* @param int $code
22+
* @param string $message
23+
* @return \Illuminate\Http\JsonResponse
24+
*/
25+
private function respond(int $code, string $message): JsonResponse
1726
{
1827
$data = [
1928
'status' => $code,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Tests\Feature\Api;
4+
5+
use Tests\TestCase;
6+
7+
class HealthResourceTest extends TestCase
8+
{
9+
/** @test */
10+
public function it_can_access_the_health_check_resource()
11+
{
12+
// ARRANGE
13+
14+
// ACT
15+
$response = $this->get('/api/health');
16+
17+
// ASSERT
18+
$response->assertStatus(200);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)