-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetmerchantstatTest.php
69 lines (58 loc) · 1.92 KB
/
GetmerchantstatTest.php
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
63
64
65
66
67
68
69
<?php
use App\Models\User;
use Tests\TestCase;
class MerchantControllerGetmerchantstatTest extends TestCase{
public function test_get_merchant_stat_success()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->getJson("/core/merchant/stats");
// Assert the response
$response->assertStatus(200);
$response->assertJson([
'success' => true,
'message' => 'Merchants stats fetched successfully'
]);
}
public function test_get_merchant_stat_with_bad_validation()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->getJson("/core/merchant/stats");
// Assert the response
$response->assertStatus(422);
$response->assertJson([
'success' => false,
'message' => 'Validation error'
]);
}
public function test_get_merchant_stat_with_failed_authentication()
{
// Call api endpoint
$response = $this->getJson("/core/merchant/stats");
// Assert the response
$response->assertStatus(401);
$response->assertJson([
'success' => false,
'message' => 'Unauthenticated'
]);
}
public function test_get_merchant_stat_with_invalid_route()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->getJson("/core/merchants/stats");
// Assert the response
$response->assertStatus(404);
$response->assertJson([
'success' => false,
'message' => 'Not Found'
]);
}
}