Skip to content
Snippets Groups Projects
Commit 3ceede6e authored by Shizuco's avatar Shizuco
Browse files

feat: category details tests

parent 39af96a7
No related branches found
No related tags found
1 merge request!3Dctn 494/fix
<?php
namespace Tests\Feature;
use App\Models\Category;
use App\Models\User;
use Hash;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class CategoryDetailsTest extends TestCase
{
public function test_success_access_to_category_details_by_admin()
{
$user = User::factory()->create([
'role' => 'admin',
'password' => Hash::make('123123123'),
]);
Sanctum::actingAs(
$user,
['*']
);
$category = Category::factory()->create();
$response = $this->get('/nova/resources/categories/' . $category->id);
$user->delete();
$category->delete();
$response->assertStatus(200);
}
public function test_success_access_to_category_details_by_analyst()
{
$user = User::factory()->create([
'role' => 'analyst',
'password' => Hash::make('123123123'),
]);
Sanctum::actingAs(
$user,
['*']
);
$category = Category::factory()->create();
$response = $this->get('/nova/resources/categories/' . $category->id);
$user->delete();
$category->delete();
$response->assertStatus(200);
}
public function test_access_to_category_detail_by_common()
{
$user = User::factory()->create([
'role' => 'common',
'password' => Hash::make('123123123'),
]);
Sanctum::actingAs(
$user,
['*']
);
$category = Category::factory()->create();
$response = $this->get('/nova/resources/categories/' . $category->id);
$user->delete();
$category->delete();
$response->assertStatus(403);
}
public function test_access_to_retailers_detail_by_unauthorized()
{
$category = Category::factory()->create();
$response = $this->get('/nova/resources/categories/' . $category->id);
$category->delete();
$response->assertStatus(302);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment