add rahdar id to road item project
This commit is contained in:
@@ -11,6 +11,7 @@ use App\Models\LogList;
|
||||
use App\Models\ObservedItem;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Province;
|
||||
use App\Models\Rahdaran;
|
||||
use App\Models\User;
|
||||
use App\Models\UserActivityLog;
|
||||
use App\Services\NominatimService;
|
||||
@@ -349,7 +350,7 @@ class StoreTest extends TestCase
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'cmms_machine_id' => __('validation.required', ['attribute' => 'cmms machine id'])
|
||||
'cmms_machine_id' => __('validation.required', ['attribute' => 'کد یکتا ماشین'])
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -367,7 +368,41 @@ class StoreTest extends TestCase
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'cmms_machine_id' => __('validation.exists', ['attribute' => 'cmms machine id'])
|
||||
'cmms_machine_id' => __('validation.exists', ['attribute' => 'کد یکتا ماشین'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_rahdar_id_is_required(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'rahdar_id' => __('validation.required', ['attribute' => 'rahdar id'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_rahdar_id_should_already_exists_on_the_table(): void
|
||||
{
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
'name' => 'create-road-item'
|
||||
]))
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), [
|
||||
'rahdar_id' => $this->faker->numberBetween(10, 100)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'rahdar_id' => __('validation.exists', ['attribute' => 'rahdar id'])
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -375,6 +410,7 @@ class StoreTest extends TestCase
|
||||
{
|
||||
$edarateOstani = EdarateOstani::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -393,7 +429,8 @@ class StoreTest extends TestCase
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
@@ -408,6 +445,7 @@ class StoreTest extends TestCase
|
||||
{
|
||||
$city = City::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -426,7 +464,8 @@ class StoreTest extends TestCase
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.road_items.store'), $data);
|
||||
@@ -442,6 +481,7 @@ class StoreTest extends TestCase
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -461,7 +501,8 @@ class StoreTest extends TestCase
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
@@ -483,6 +524,7 @@ class StoreTest extends TestCase
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -500,7 +542,8 @@ class StoreTest extends TestCase
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
@@ -522,6 +565,7 @@ class StoreTest extends TestCase
|
||||
$city = City::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
$user = User::factory()
|
||||
->has(Permission::factory([
|
||||
@@ -539,7 +583,8 @@ class StoreTest extends TestCase
|
||||
'amount' => $this->faker->numberBetween(1, 10),
|
||||
'activity_date' => $this->faker->date(),
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
InfoItem::factory()->create([
|
||||
@@ -562,6 +607,7 @@ class StoreTest extends TestCase
|
||||
$province = Province::factory()->create();
|
||||
$edarateShari = EdarateShahri::factory()->create();
|
||||
$cmmsMachine = CMMSMachine::factory()->create();
|
||||
$rahdar = Rahdaran::factory()->create();
|
||||
|
||||
LogList::factory()->create([
|
||||
'log_unique_code' => 1154
|
||||
@@ -595,7 +641,8 @@ class StoreTest extends TestCase
|
||||
'activity_time' => $this->faker->date('H:i'),
|
||||
'before_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'after_image' => UploadedFile::fake()->create('image.jpg', 10),
|
||||
'cmms_machine_id' => $cmmsMachine->id
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
];
|
||||
|
||||
$infoItem = InfoItem::factory()->create([
|
||||
@@ -625,7 +672,9 @@ class StoreTest extends TestCase
|
||||
'status_fa' => 'در حال بررسی',
|
||||
'edarat_id' => $user->edarate_shahri_id,
|
||||
'cmms_machine_id' => $cmmsMachine->id,
|
||||
'cmms_machine_code' => $cmmsMachine->machine_code
|
||||
'cmms_machine_code' => $cmmsMachine->machine_code,
|
||||
'rahdar_id' => $rahdar->id,
|
||||
'rahdar_code' => $rahdar->code
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_activity_logs', [
|
||||
|
||||
Reference in New Issue
Block a user