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

feat: delete product test

parent 9169f2f4
No related branches found
No related tags found
1 merge request!3Dctn 494/fix
<?php
namespace Tests\Feature;
use App\Models\Product;
use App\Models\User;
use Hash;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class ProductDeleteTest extends TestCase
{
public function test_success_delete_retailer_by_admin()
{
$user = User::factory()->create([
'role' => 'admin',
'password' => Hash::make('123123123'),
]);
$product = Product::factory()->create();
Sanctum::actingAs(
$user,
['*']
);
$response = $this->delete('nova-api/products?filters=W10%3D&resources[]=' . $product->id);
$user->delete();
$response->assertStatus(200);
}
public function test_success_delete_retailer_by_analyst()
{
$user = User::factory()->create([
'role' => 'analyst',
'password' => Hash::make('123123123'),
]);
$product = Product::factory()->create();
Sanctum::actingAs(
$user,
['*']
);
$response = $this->delete('nova-api/products?filters=W10%3D&resources[]=' . $product->id);
$user->delete();
$response->assertStatus(200);
}
public function test_delete_retailer_by_common()
{
$user = User::factory()->create([
'role' => 'common',
'password' => Hash::make('123123123'),
]);
Sanctum::actingAs(
$user,
['*']
);
$product = Product::factory()->create();
$response = $this->delete('nova-api/products?filters=W10%3D&resources[]=' . $product->id);
$product->delete();
$user->delete();
$response->assertStatus(403);
}
public function test_delete_retailer_by_unauthenticate_user()
{
$product = Product::factory()->create();
$response = $this->delete('nova-api/products?filters=W10%3D&resources[]=' . $product->id);
$product->delete();
$response->assertStatus(401);
}
}
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ProductUpdateTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
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