write test for road item projects
This commit is contained in:
74
tests/Feature/V2/Dashboard/RoadItemsProject/DeleteTest.php
Normal file
74
tests/Feature/V2/Dashboard/RoadItemsProject/DeleteTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V2\Dashboard\RoadItemsProject;
|
||||
|
||||
use App\Models\City;
|
||||
use App\Models\EdarateOstani;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\LogList;
|
||||
use App\Models\ObservedItem;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Province;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
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();
|
||||
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/v2/road_items/supervisor/cartable/delete/{$roadItem->id}");
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_can_delete_a_road_item_project(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'delete-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$roadItem = RoadItemsProject::factory()->create();
|
||||
|
||||
$logList = LogList::factory()->create([
|
||||
'log_unique_code' => 1151
|
||||
]);
|
||||
|
||||
$userActivityLog = UserActivityLog::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson("/v2/road_items/supervisor/cartable/delete/{$roadItem->id}");
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'status' => 'succeed',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('road_items_projects', [
|
||||
'item' => $roadItem->item,
|
||||
'sub_item' => $roadItem->sub_item,
|
||||
'start_lat' => $roadItem->start_lat,
|
||||
'start_lng' => $roadItem->start_lng,
|
||||
'sub_item_data' => $roadItem->sub_item_data,
|
||||
'status' => $roadItem->status,
|
||||
'status_fa' => $roadItem->status_fa,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user