-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGettransactionsTest.php
More file actions
77 lines (68 loc) · 2.08 KB
/
GettransactionsTest.php
File metadata and controls
77 lines (68 loc) · 2.08 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
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
<?php
use App\Models\User;
use Tests\TestCase;
class ProviderControllerGettransactionsTest extends TestCase
{
public function test_valid_request_success()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson(
'/provider/collection/transactions',
[
'account_reference' => $user->account_number
]
);
// Assert the response
$response->assertStatus(200);
$response->assertJsonStructure(['data', 'message']);
}
public function test_invalid_request_validation_failure()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson(
'/provider/collection/transactions',
[
'account_reference' => 12345
]
);
// Assert the response
$response->assertStatus(422);
$response->assertJson(
[
'message' => 'The given data was invalid.',
'errors' => [
'account_reference' => [
'The account reference must exist.',
],
],
]
);
}
public function test_invalid_request_server_error()
{
// Create a user and authenticate
$user = User::factory()->create();
$this->actingAs($user);
// Call api endpoint
$response = $this->postJson(
'/provider/collection/transactions',
[
'account_reference' => $user->account_number
]
);
$this->service->shouldReceive('getCustomerAccountTransaction')->andThrow(\Exception::class);
// Assert the response
$response->assertStatus(500);
$response->assertJson(
[
'message' => 'This service is not availabe for your provider',
]
);
}
}