-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcceptrequestTest.php
85 lines (72 loc) · 2.56 KB
/
AcceptrequestTest.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
use App\Models\User;
use App\Models\WalletRequest;
use App\Models\VirtualAccount;
use App\Models\WalletTransaction;
use Tests\TestCase;
class WalletRequestControllerAcceptrequestTest extends TestCase
{
public function testAcceptRequestSuccess()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Create a wallet request
$walletRequest = WalletRequest::factory()->create();
// Create a virtual account
$debitAcWallet = VirtualAccount::factory()->create([
'account_number' => $walletRequest->dbaccount_no,
]);
// Call api endpoint
$response = $this->postJson("/approve/{$walletRequest->wallet_request_id}", [
'amount' => $walletRequest->amount,
'bank_code' => $walletRequest->craccount_bank_code,
'account_number' => $walletRequest->craccount_no,
'account_name' => $walletRequest->craccount_name,
'wallet_id' => $debitAcWallet->wallet_id,
'request_payment_id' => $walletRequest->wallet_request_id,
'type' => "request",
]);
// Assert the response
$response->assertStatus(200);
$response->assertJsonStructure([
'success',
'data',
'message'
]);
}
public function testAcceptRequestNotFound()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Create a wallet request
$walletRequest = WalletRequest::factory()->create();
// Call api endpoint
$response = $this->postJson("/approve/{$walletRequest->wallet_request_id}");
// Assert the response
$response->assertStatus(400);
$response->assertJson([
'success' => false,
'message' => 'Wallet request not found',
]);
}
public function testAcceptRequestAlreadyApproved()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Create a wallet request
$walletRequest = WalletRequest::factory()->create([
'status' => WalletTransaction::$status["approved"],
]);
// Call api endpoint
$response = $this->postJson("/approve/{$walletRequest->wallet_request_id}");
// Assert the response
$response->assertStatus(400);
$response->assertJson([
'success' => false,
'message' => 'Request already approved',
]);
}
}