mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
* Create PHP CS Fixer config and add to CI workflow * Run php cs fixer on project * Add newline at end of file * Update to use PHP CS Fixer v3 * Run v3 config on project * Run seperate config in CI
95 lines
2.2 KiB
PHP
95 lines
2.2 KiB
PHP
<?php
|
|
|
|
use Crater\Http\Controllers\V1\Settings\TaxTypesController;
|
|
use Crater\Http\Requests\TaxTypeRequest;
|
|
use Crater\Models\TaxType;
|
|
use Crater\Models\User;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
use Laravel\Sanctum\Sanctum;
|
|
|
|
use function Pest\Laravel\deleteJson;
|
|
use function Pest\Laravel\getJson;
|
|
use function Pest\Laravel\postJson;
|
|
use function Pest\Laravel\putJson;
|
|
|
|
beforeEach(function () {
|
|
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
|
|
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
|
|
|
|
$user = User::find(1);
|
|
$this->withHeaders([
|
|
'company' => $user->company_id,
|
|
]);
|
|
Sanctum::actingAs(
|
|
$user,
|
|
['*']
|
|
);
|
|
});
|
|
|
|
test('get tax types', function () {
|
|
$response = getJson('api/v1/tax-types');
|
|
|
|
$response->assertOk();
|
|
});
|
|
|
|
test('create tax type', function () {
|
|
$taxType = TaxType::factory()->raw();
|
|
|
|
postJson('api/v1/tax-types', $taxType);
|
|
|
|
$this->assertDatabaseHas('tax_types', $taxType);
|
|
});
|
|
|
|
test('store validates using a form request', function () {
|
|
$this->assertActionUsesFormRequest(
|
|
TaxTypesController::class,
|
|
'store',
|
|
TaxTypeRequest::class
|
|
);
|
|
});
|
|
|
|
test('get tax type', function () {
|
|
$taxType = TaxType::factory()->create();
|
|
|
|
$response = getJson('api/v1/tax-types/'.$taxType->id);
|
|
|
|
$response->assertOk()
|
|
->assertJson([
|
|
'taxType' => $taxType->toArray(),
|
|
]);
|
|
});
|
|
|
|
test('update tax type', function () {
|
|
$taxType = TaxType::factory()->create();
|
|
|
|
$taxType1 = TaxType::factory()->raw();
|
|
|
|
$response = putJson('api/v1/tax-types/'.$taxType->id, $taxType1);
|
|
|
|
$response->assertOk()
|
|
->assertJson([
|
|
'taxType' => $taxType1,
|
|
]);
|
|
});
|
|
|
|
test('update validates using a form request', function () {
|
|
$this->assertActionUsesFormRequest(
|
|
TaxTypesController::class,
|
|
'update',
|
|
TaxTypeRequest::class
|
|
);
|
|
});
|
|
|
|
test('delete tax type', function () {
|
|
$taxType = TaxType::factory()->create();
|
|
|
|
$response = deleteJson('api/v1/tax-types/'.$taxType->id);
|
|
|
|
$response->assertOk()
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
|
|
$this->assertDeleted($taxType);
|
|
});
|