diff --git a/tests/Api/GeneralTest.php b/tests/Api/GeneralTest.php index ef153884..637d44c8 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' + ] + ]); + } }