ERP-API/tests/Feature/Accounting/Account/DeleteTest.php

43 lines
995 B
PHP

<?php
namespace Tests\Feature\Accounting\Account;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\Account;
use App\Models\Role;
use App\Models\Permission;
use App\Models\User;
use Laravel\Sanctum\Sanctum;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class DeleteTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic feature test example.
*/
public function test_success(): void
{
$permission = Permission::where("code","accounting.account:delete")->first();
$role = Role::factory()->create();
$role->permissions()->attach($permission->id);
$user = User::factory()->create();
$user->roles()->attach($role->id);
Sanctum::actingAs($user);
$data = Account::factory()->create();
$response = $this->post('/accounting/account/'.$data->id.'/delete');
$response->assertStatus(200);
}
}