write test for safety and privacy controller
This commit is contained in:
51
tests/Feature/V2/Dashboard/SafetyAndPrivacy/DeleteTest.php
Normal file
51
tests/Feature/V2/Dashboard/SafetyAndPrivacy/DeleteTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V2\Dashboard\SafetyAndPrivacy;
|
||||
|
||||
use App\Models\LogList;
|
||||
use App\Models\Permission;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_user_should_have_delete_road_item_permission(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$safetyAndPrivacy = SafetyAndPrivacy::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson("v2/safety_and_privacy/delete/{$safetyAndPrivacy->id}");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_can_delete_a_safety_and_privacy(): void
|
||||
{
|
||||
$safetyAndPrivacy = SafetyAndPrivacy::factory()->create();
|
||||
$logList = LogList::factory()->create([
|
||||
'log_unique_code' => 1155
|
||||
]);
|
||||
$userActivityLog = UserActivityLog::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'delete-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson("v2/safety_and_privacy/delete/{$safetyAndPrivacy->id}");
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertExactJson([
|
||||
'status' => 'succeed'
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user