-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathStatusTest.php
More file actions
62 lines (53 loc) · 1.62 KB
/
StatusTest.php
File metadata and controls
62 lines (53 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Tests;
use Exception;
use Illuminate\Cache\ArrayStore;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
use Mockery;
class StatusTest extends TestCase
{
public function test_returns_json_with_expected_results()
{
$resp = $this->get('/status');
$resp->assertStatus(200);
$resp->assertJson([
'database' => true,
'cache' => true,
'session' => true,
]);
}
public function test_returns_500_status_and_false_on_db_error()
{
DB::shouldReceive('table')->andThrow(new Exception());
$resp = $this->get('/status');
$resp->assertStatus(500);
$resp->assertJson([
'database' => false,
]);
}
public function test_returns_500_status_and_false_on_wrong_cache_return()
{
$mockStore = Mockery::mock(new ArrayStore())->makePartial();
Cache::swap($mockStore);
$mockStore->shouldReceive('pull')->andReturn('cat');
$resp = $this->get('/status');
$resp->assertStatus(500);
$resp->assertJson([
'cache' => false,
]);
}
public function test_returns_500_status_and_false_on_wrong_session_return()
{
$session = Session::getFacadeRoot();
$mockSession = Mockery::mock($session)->makePartial();
Session::swap($mockSession);
$mockSession->shouldReceive('get')->andReturn('cat');
$resp = $this->get('/status');
$resp->assertStatus(500);
$resp->assertJson([
'session' => false,
]);
}
}