write test for search codes
This commit is contained in:
@@ -23,7 +23,7 @@ class CMMSMachinesController extends Controller
|
|||||||
{
|
{
|
||||||
$matchedSearchedMachines = CMMSMachine::query()
|
$matchedSearchedMachines = CMMSMachine::query()
|
||||||
->where('machine_code', 'LIKE', "%{$request->machine_code}%")
|
->where('machine_code', 'LIKE', "%{$request->machine_code}%")
|
||||||
->get();
|
->get(['machine_code']);
|
||||||
|
|
||||||
return $this->successResponse($matchedSearchedMachines);
|
return $this->successResponse($matchedSearchedMachines);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class VerifyBySupervisorRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return Gate::allows('gate-supervise-road-item', $this->road_item);
|
return Gate::allows('gate-supervise-road-item', $this->roadItemsProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ Route::prefix('road_items')
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('cmms_machines')
|
Route::prefix('cmms_machines')
|
||||||
->name('cmms_machines')
|
->name('cmms_machines.')
|
||||||
->controller(CMMSMachinesController::class)
|
->controller(CMMSMachinesController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/list', 'list')->name('list');
|
Route::get('/list', 'list')->name('list');
|
||||||
@@ -126,7 +126,7 @@ Route::prefix('cmms_machines')
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('rahdaran')
|
Route::prefix('rahdaran')
|
||||||
->name('rahdaran')
|
->name('rahdaran.')
|
||||||
->controller(RahdaranController::class)
|
->controller(RahdaranController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/list', 'list')->name('list');
|
Route::get('/list', 'list')->name('list');
|
||||||
|
|||||||
35
tests/Feature/V3/CMMSMachine/SearchTest.php
Normal file
35
tests/Feature/V3/CMMSMachine/SearchTest.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\CMMSMachine;
|
||||||
|
|
||||||
|
use App\Models\CMMSMachine;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SearchTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase, WithFaker;
|
||||||
|
/**
|
||||||
|
* A basic feature test example.
|
||||||
|
*/
|
||||||
|
public function test_user_can_search_through_machine_codes(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$machine = CMMSMachine::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.cmms_machines.search', [$machine->machine_code]));
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
$response->assertJsonStructure([
|
||||||
|
'data' => [
|
||||||
|
'*' => [
|
||||||
|
"machine_code",
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
tests/Feature/V3/Rahdaran/SearchTest.php
Normal file
36
tests/Feature/V3/Rahdaran/SearchTest.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\V3\Rahdaran;
|
||||||
|
|
||||||
|
use App\Models\Rahdaran;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\WithFaker;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class SearchTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
/**
|
||||||
|
* A basic feature test example.
|
||||||
|
*/
|
||||||
|
public function test_user_can_search_through_rahdaran_codes(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$rahdar = Rahdaran::factory()->create();
|
||||||
|
|
||||||
|
$response = $this->actingAs($user)->getJson(route('v3.cmms_machines.search', [$rahdar->code]));
|
||||||
|
|
||||||
|
$response->assertOk();
|
||||||
|
|
||||||
|
$response->assertJsonStructure([
|
||||||
|
'data' => [
|
||||||
|
'*' => [
|
||||||
|
"name",
|
||||||
|
"code",
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user