write test for search codes
This commit is contained in:
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