From 5157e67f5048042b97c3118ce52f816c8cfa03e8 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Tue, 19 Feb 2019 07:30:28 +0000 Subject: [PATCH] Add status API tests --- tests/Api/GeneralTest.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Api/GeneralTest.php b/tests/Api/GeneralTest.php index ef1538844..637d44c87 100644 --- a/tests/Api/GeneralTest.php +++ b/tests/Api/GeneralTest.php @@ -11,6 +11,8 @@ namespace CachetHQ\Tests\Cachet\Api; +use CachetHQ\Cachet\Models\Component; + /** * This is the general test class. * @@ -42,4 +44,36 @@ class GeneralTest extends AbstractApiTestCase $response->assertStatus(406); } + + public function test_can_get_system_status() + { + $response = $this->json('GET', '/api/v1/status'); + + $response->assertStatus(200) + ->assertHeader('Cache-Control') + ->assertJsonFragment([ + 'data' => [ + 'status' => 'success', + 'message' => 'System operational' + ] + ]); + } + + public function test_can_get_system_status_not_success() + { + factory(Component::class)->create([ + 'status' => 3, + ]); + + $response = $this->json('GET', '/api/v1/status'); + + $response->assertStatus(200) + ->assertHeader('Cache-Control') + ->assertJsonFragment([ + 'data' => [ + 'status' => 'info', + 'message' => 'The system is experiencing issues' + ] + ]); + } }