write tests for azmayesh resources
This commit is contained in:
86
tests/Feature/V3/AzmayeshSample/IndexTest.php
Normal file
86
tests/Feature/V3/AzmayeshSample/IndexTest.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshSample;
|
||||
|
||||
use App\Models\Azmayesh;
|
||||
use App\Models\AzmayeshSample;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IndexTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_all_azmayesh_samples_returned_successfully(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Azmayesh::factory(5)
|
||||
->sequence(
|
||||
['id' => 1],
|
||||
['id' => 2],
|
||||
['id' => 3],
|
||||
['id' => 4],
|
||||
['id' => 5]
|
||||
)
|
||||
->create();
|
||||
|
||||
AzmayeshSample::factory(5)
|
||||
->sequence(
|
||||
[
|
||||
'azmayesh_id' => 1,
|
||||
'azmayesh_project_name' => $this->faker->name,
|
||||
'data' => json_encode([$this->faker->numerify]),
|
||||
],
|
||||
[
|
||||
'azmayesh_id' => 2,
|
||||
'azmayesh_project_name' => $this->faker->name,
|
||||
'data' => json_encode([$this->faker->numerify]),
|
||||
],
|
||||
[
|
||||
'azmayesh_id' => 3,
|
||||
'azmayesh_project_name' => $this->faker->name,
|
||||
'data' => json_encode([$this->faker->numerify]),
|
||||
],
|
||||
[
|
||||
'azmayesh_id' => 4,
|
||||
'azmayesh_project_name' => $this->faker->name,
|
||||
'data' => json_encode([$this->faker->numerify]),
|
||||
],
|
||||
[
|
||||
'azmayesh_id' => 1,
|
||||
'azmayesh_project_name' => $this->faker->name,
|
||||
'data' => json_encode([$this->faker->numerify]),
|
||||
],
|
||||
)
|
||||
->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_samples.index', [
|
||||
1,
|
||||
'start' => 0,
|
||||
'size' => 10,
|
||||
'filters' => json_encode([]),
|
||||
'sorting' => json_encode([]),
|
||||
]));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$response->assertJsonStructure([
|
||||
'data' => [
|
||||
'*' => [
|
||||
'id',
|
||||
'azmayesh_id',
|
||||
'azmayesh_project_name',
|
||||
'data',
|
||||
],
|
||||
],
|
||||
"meta" => [
|
||||
"totalRowCount"
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user