-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemowebhookwemaTest.php
49 lines (43 loc) · 1.36 KB
/
DemowebhookwemaTest.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
<?php
use App\Models\User;
use Tests\TestCase;
class VirtualAccountControllerDemowebhookwemaTest extends TestCase
{
public function test_when_valid_request_is_made_then_200_status_code_is_returned(){
// Call api endpoint
$response = $this->postJson('/webhook/demo/wema', [
'data' => [
'name' => 'John'
]
]);
// Assert response
$response->assertStatus(200);
}
public function test_when_bad_request_is_made_then_400_status_code_is_returned(){
// Call api endpoint
$response = $this->postJson('/webhook/demo/wema', [
'data' => []
]);
// Assert response
$response->assertStatus(400);
$response->assertJsonStructure([
'message'
]);
}
public function test_when_unauthorized_request_is_made_then_401_status_code_is_returned(){
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson('/webhook/demo/wema', [
'data' => [
'name' => 'John'
]
]);
// Assert response
$response->assertStatus(401);
$response->assertJsonStructure([
'message'
]);
}
}