ERP-API/tests/Feature/Auth/Role/DeleteTest.php

41 lines
940 B
PHP

<?php
namespace Tests\Feature\Auth\Role;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
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","auth.user:delete")->first();
$role = Role::factory()->create();
$role->permissions()->attach($permission->id);
$user = User::factory()->create();
$user->roles()->attach($role->id);
Sanctum::actingAs($user);
$data = User::factory()->create();
$response = $this->post('/auth/user/'.$data->id.'/delete');
$response->assertStatus(200);
}
}