forked from crater-invoice-inc/crater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaxTest.php
65 lines (49 loc) · 1.64 KB
/
TaxTest.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
<?php
use Crater\Models\User;
use Crater\Models\Tax;
use Crater\Models\Estimate;
use Crater\Models\EstimateItem;
use Crater\Models\Invoice;
use Crater\Models\InvoiceItem;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$user = User::where('role', 'super admin')->first();
$this->withHeaders([
'company' => $user->company_id,
]);
Sanctum::actingAs(
$user,
['*']
);
});
test('tax belongs to tax type', function () {
$tax = Tax::factory()->create();
$this->assertTrue($tax->taxType->exists());
});
test('tax belongs to invoice', function () {
$tax = Tax::factory()->forInvoice()->create();
$this->assertTrue($tax->invoice()->exists());
});
test('tax belongs to estimate', function () {
$tax = Tax::factory()->forEstimate()->create();
$this->assertTrue($tax->estimate()->exists());
});
test('tax belongs to invoice item', function () {
$tax = Tax::factory()->for(InvoiceItem::factory()->state([
'invoice_id' => Invoice::factory()
]))->create();
$this->assertTrue($tax->invoiceItem()->exists());
});
test('tax belongs to estimate item', function () {
$tax = Tax::factory()->for(EstimateItem::factory()->state([
'estimate_id' => Estimate::factory()
]))->create();
$this->assertTrue($tax->estimateItem()->exists());
});
test('tax belongs to item', function () {
$tax = Tax::factory()->forItem()->create();
$this->assertTrue($tax->item()->exists());
});