-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChart_dataTest.php
More file actions
43 lines (36 loc) · 1.41 KB
/
Chart_dataTest.php
File metadata and controls
43 lines (36 loc) · 1.41 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
<?php
use App\Models\User;
use Tests\TestCase;
class DashboardAnalyticsControllerChart_dataTest extends TestCase
{
public function test_chart_data_success(){
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson("/core/general/chart_data", ['days' => 7]);
// Assert the response
$response->assertStatus(200);
$response->assertJson(['success' => true]);
$response->assertJsonStructure(['success', 'data' => ['dates', 'amounts']]);
}
public function test_chart_data_bad_validation(){
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson("/core/general/chart_data");
// Assert the response
$response->assertStatus(422);
$response->assertJson(['success' => false]);
$response->assertJsonStructure(['success', 'message']);
}
public function test_chart_data_user_not_authenticated(){
// Call api endpoint
$response = $this->postJson("/core/general/chart_data", ['days' => 7]);
// Assert the response
$response->assertStatus(401);
$response->assertJson(['success' => false]);
$response->assertJsonStructure(['success', 'message']);
}
}