-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoactivateaccountTest.php
90 lines (78 loc) · 2.54 KB
/
DemoactivateaccountTest.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
86
87
88
89
90
<?php
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\User;
use App\Models\Merchant;
use App\Models\Account;
use Tests\TestCase;
class AccountControllerDemoactivateaccountTest extends TestCase
{
use RefreshDatabase;
// Test success case
public function testSuccessDemoActivateAccount()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Create a merchant
$merchant = Merchant::factory()->create();
// Create an account
$account = Account::factory()->create([
'account_id' => $merchant->account_id,
'user_id' => $merchant->user_id,
'type' => 'Default',
'name' => $merchant->name,
'status' => 'INACTIVE',
]);
// Call demoActivate api endpoint
$response = $this->postJson("/demo-activate/{$account->id}");
// Assert the response
$response->assertStatus(200)
->assertJson([
'success' => true,
'message' => 'You have successfully activated this Account!'
]);
}
// Test failure case
public function testFailedDemoActivateAccount()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call demoActivate api endpoint
$response = $this->postJson("/demo-activate/{$account->id}");
// Assert the response
$response->assertStatus(404)
->assertJson([
'success' => false,
'message' => 'Account Not Found!'
]);
}
// Test bad validation case
public function testBadValidationDemoActivateAccount()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call demoActivate api endpoint
$response = $this->postJson("/demo-activate/{$account->id}", [
'wallet_type' => '',
'account_id' => '',
'personal_id' => '',
'merchant_id' => '',
'settlement_bank_id' => '',
'name' => '',
'description' => ''
]);
// Assert the response
$response->assertStatus(422)
->assertJsonValidationErrors([
'wallet_type',
'account_id',
'personal_id',
'merchant_id',
'settlement_bank_id',
'name',
'description'
]);
}
}