-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetmerchantdataTest.php
More file actions
61 lines (54 loc) · 1.55 KB
/
GetmerchantdataTest.php
File metadata and controls
61 lines (54 loc) · 1.55 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
<?php
use App\Models\Merchant;
use Tests\TestCase;
class ComplianceControllerGetmerchantdataTest extends TestCase
{
public function test_merchant_data_success()
{
// Create a merchant
$merchant = Merchant::factory()->create([
'public_key' => '1234567890'
]);
// Call api endpoint
$response = $this->postJson("/merchant_data", [
'public_key' => $merchant->public_key
]);
// Assert the response
$response->assertStatus(200);
$response->assertExactJson([
'success' => true,
'data' => $merchant->toArray()
]);
}
public function test_merchant_data_not_found()
{
// Call api endpoint
$response = $this->postJson("/merchant_data", [
'public_key' => '1234567890'
]);
// Assert the response
$response->assertStatus(200);
$response->assertExactJson([
'success' => true,
'data' => null
]);
}
public function test_merchant_data_bad_validation()
{
// Call api endpoint
$response = $this->postJson("/merchant_data", [
'public_key' => ''
]);
// Assert the response
$response->assertStatus(422);
$response->assertExactJson([
'success' => false,
'message' => 'The given data was invalid.',
'errors' => [
'public_key' => [
'The public key field is required.'
]
]
]);
}
}