-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcceptcontractTest.php
More file actions
41 lines (36 loc) · 1.22 KB
/
AcceptcontractTest.php
File metadata and controls
41 lines (36 loc) · 1.22 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
<?php
use App\Models\User;
use App\Models\Contract\ContractSubaccount;
use App\Models\Contract\Contract;
use Tests\TestCase;
class ContractControllerAcceptcontractTest extends TestCase
{
public function test_accept_contract_success()
{
$user = User::factory()->create();
$this->actingAs($user);
$token = Str::random(10);
$contract = ContractSubaccount::factory()->create([
'email_code' => $token,
'access_type' => 'personal',
'user_id' => $user->id
]);
$contracts = Contract::factory()->create([
'id' => $contract->contract_id,
]);
$response = $this->getJson("/accept/{$token}");
$response->assertStatus(200);
$response->assertJson(['success' => true]);
$response->assertJson(['data' => $contracts]);
}
public function test_accept_contract_not_found()
{
$user = User::factory()->create();
$this->actingAs($user);
$token = Str::random(10);
$response = $this->getJson("/accept/{$token}");
$response->assertStatus(404);
$response->assertJson(['success' => false]);
$response->assertJson(['message' => 'Contract not found']);
}
}