write test for azmayesh type entity
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature\V3\AzmayeshSample;
|
||||
|
||||
use App\Models\Azmayesh;
|
||||
use App\Models\AzmayeshSample;
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\Province;
|
||||
use App\Models\User;
|
||||
@@ -73,7 +74,9 @@ class StoreTest extends TestCase
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_samples', [
|
||||
'azmayesh_id' => $data['azmayesh_id'],
|
||||
'data' => $data['data'],
|
||||
// 'data' => $data['data'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(AzmayeshSample::first()->data, $data['data']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,9 @@ class UpdateTest extends TestCase
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_samples', [
|
||||
'azmayesh_id' => $data['azmayesh_id'],
|
||||
'data' => $data['data'],
|
||||
// 'data' => $data['data'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(AzmayeshSample::first()->data, $data['data']);
|
||||
}
|
||||
}
|
||||
|
||||
43
tests/Feature/V3/AzmayeshType/DeleteTest.php
Normal file
43
tests/Feature/V3/AzmayeshType/DeleteTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshType;
|
||||
|
||||
use App\Models\AzmayeshField;
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_user_can_delete_azmayesh_type(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
$azmayeshField = AzmayeshField::factory()->create();
|
||||
|
||||
$azmayeshType->azmayeshFields()->attach([$azmayeshField->id]);
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.delete', [$azmayeshType->id]));
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'message' => __('messages.successful')
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('azmayesh_types', [
|
||||
'name' => $azmayeshType->name,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('azmayesh_field_azmayesh_type', [
|
||||
'azmayesh_type_id' => $azmayeshType->id,
|
||||
'azmayesh_field_id' => $azmayeshField->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -24,25 +24,28 @@ class FieldsTest extends TestCase
|
||||
'name' => $this->faker->name,
|
||||
'unit' => $this->faker->name,
|
||||
'type' => $this->faker->name,
|
||||
'option' => json_encode([$this->faker->name]),
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => $this->faker->name,
|
||||
'unit' => $this->faker->name,
|
||||
'type' => $this->faker->name,
|
||||
'option' => json_encode([$this->faker->name]),
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => $this->faker->name,
|
||||
'unit' => $this->faker->name,
|
||||
'type' => $this->faker->name,
|
||||
'option' => json_encode([$this->faker->name]),
|
||||
],
|
||||
)
|
||||
->create();
|
||||
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$azmayeshType->azmayeshFields()->attach(1);
|
||||
$azmayeshType->azmayeshFields()->attach([1, 2, 3]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
@@ -56,7 +59,9 @@ class FieldsTest extends TestCase
|
||||
'name',
|
||||
'unit',
|
||||
'type',
|
||||
'option'
|
||||
'option',
|
||||
"created_at",
|
||||
"updated_at"
|
||||
],
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -20,13 +20,19 @@ class IndexTest extends TestCase
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.index'));
|
||||
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.index', [
|
||||
'start' => 0,
|
||||
'size' => 10,
|
||||
'filters' => json_encode([]),
|
||||
'sorting' => json_encode([]),
|
||||
]));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$response->assertJsonStructure([
|
||||
'data' => [
|
||||
'*' => [
|
||||
'id',
|
||||
'name',
|
||||
],
|
||||
]
|
||||
|
||||
35
tests/Feature/V3/AzmayeshType/ListTest.php
Normal file
35
tests/Feature/V3/AzmayeshType/ListTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshType;
|
||||
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ListTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_azmayesh_type_list_returned_successfully(): void
|
||||
{
|
||||
AzmayeshType::factory(5)->create();
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.list'));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$response->assertJsonStructure([
|
||||
'data' => [
|
||||
'*' => [
|
||||
'name',
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
51
tests/Feature/V3/AzmayeshType/ShowTest.php
Normal file
51
tests/Feature/V3/AzmayeshType/ShowTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshType;
|
||||
|
||||
use App\Models\AzmayeshField;
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ShowTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_azmayesh_type_details_returned_successfully(): void
|
||||
{
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
$azmayeshField = AzmayeshField::factory()->create();
|
||||
|
||||
$azmayeshType->azmayeshFields()->attach([$azmayeshField->id]);
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->getJson(route('v3.azmayesh_types.show', [$azmayeshType->id]));
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$response->assertExactJson([
|
||||
'data' => [
|
||||
"id" => $azmayeshType->id,
|
||||
"name" => $azmayeshType->name,
|
||||
"created_at" => $azmayeshType->created_at,
|
||||
"updated_at" => $azmayeshType->updated_at,
|
||||
"azmayesh_fields" => [
|
||||
[
|
||||
"id" => $azmayeshField->id,
|
||||
"name" => $azmayeshField->name,
|
||||
"unit" => $azmayeshField->unit,
|
||||
"type" => $azmayeshField->type,
|
||||
"option" => $azmayeshField->option,
|
||||
"created_at" => $azmayeshField->created_at,
|
||||
"updated_at" => $azmayeshField->updated_at,
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
208
tests/Feature/V3/AzmayeshType/StoreTest.php
Normal file
208
tests/Feature/V3/AzmayeshType/StoreTest.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshType;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StoreTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_name_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.required', ['attribute' => "نام"])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'name' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.string', ['attribute' => "نام"])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_fields_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields' => __('validation.required', ['attribute' => 'فیلد ها'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_fields_attribute_should_be_array(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields' => __('validation.array', ['attribute' => 'فیلد ها'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_name_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
[]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.name' => __('validation.required', ['attribute' => 'نام فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_name_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
['name' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.name' => __('validation.string', ['attribute' => 'نام فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_unit_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
['unit' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.unit' => __('validation.string', ['attribute' => 'واحد فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_type_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
[]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.type' => __('validation.required', ['attribute' => 'نوع فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_type_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
['type' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.type' => __('validation.string', ['attribute' => 'نوع فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_option_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), [
|
||||
'fields' => [
|
||||
['option' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.option' => __('validation.string', ['attribute' => 'گزینه های فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_user_can_store_fields_for_an_azmayesh_type(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$data = [
|
||||
'name' => $this->faker->name,
|
||||
'fields' => [
|
||||
[
|
||||
'name' => $this->faker->name,
|
||||
'type' => $this->faker->randomElement(['input', 'select', 'date']),
|
||||
'unit' => $this->faker->name,
|
||||
'option' => json_encode(['test']),
|
||||
],
|
||||
[
|
||||
'name' => $this->faker->name,
|
||||
'type' => $this->faker->randomElement(['input', 'select', 'date']),
|
||||
'unit' => $this->faker->name,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.store'), $data);
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'message' => __('messages.successful')
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_fields', [
|
||||
'name' => $data['fields'][0]['name'],
|
||||
'type' => $data['fields'][0]['type'],
|
||||
'unit' => $data['fields'][0]['unit'],
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_fields', [
|
||||
'name' => $data['fields'][1]['name'],
|
||||
'type' => $data['fields'][1]['type'],
|
||||
'unit' => $data['fields'][1]['unit'],
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_types', [
|
||||
'name' => $data['name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
220
tests/Feature/V3/AzmayeshType/UpdateTest.php
Normal file
220
tests/Feature/V3/AzmayeshType/UpdateTest.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\V3\AzmayeshType;
|
||||
|
||||
use App\Models\AzmayeshType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase, WithFaker;
|
||||
/**
|
||||
* A basic feature test example.
|
||||
*/
|
||||
public function test_name_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.required', ['attribute' => "نام"])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_name_attribute_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'name' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'name' => __('validation.string', ['attribute' => "نام"])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_fields_attribute_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]));
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields' => __('validation.required', ['attribute' => 'فیلد ها'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_fields_attribute_should_be_array(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => $this->faker->numberBetween(1, 10)
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields' => __('validation.array', ['attribute' => 'فیلد ها'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_name_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
[]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.name' => __('validation.required', ['attribute' => 'نام فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_name_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
['name' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.name' => __('validation.string', ['attribute' => 'نام فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_unit_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
['unit' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.unit' => __('validation.string', ['attribute' => 'واحد فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_type_is_required(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
[]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.type' => __('validation.required', ['attribute' => 'نوع فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_type_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
['type' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.type' => __('validation.string', ['attribute' => 'نوع فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_field_option_should_be_string(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), [
|
||||
'fields' => [
|
||||
['option' => $this->faker->numberBetween(1, 10)]
|
||||
]
|
||||
]);
|
||||
|
||||
$response->assertUnprocessable()
|
||||
->assertInvalid([
|
||||
'fields.0.option' => __('validation.string', ['attribute' => 'گزینه های فیلد'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_user_can_update_fields_for_an_azmayesh_type(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$azmayeshType = AzmayeshType::factory()->create();
|
||||
|
||||
$data = [
|
||||
'name' => $this->faker->name,
|
||||
'fields' => [
|
||||
[
|
||||
'name' => $this->faker->name,
|
||||
'type' => $this->faker->randomElement(['input', 'select', 'date']),
|
||||
'unit' => $this->faker->name,
|
||||
'option' => json_encode(['test']),
|
||||
],
|
||||
[
|
||||
'name' => $this->faker->name,
|
||||
'type' => $this->faker->randomElement(['input', 'select', 'date']),
|
||||
'unit' => $this->faker->name,
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
$response = $this->actingAs($user)->postJson(route('v3.azmayesh_types.update', [$azmayeshType->id]), $data);
|
||||
|
||||
$response->assertOk()
|
||||
->assertExactJson([
|
||||
'message' => __('messages.successful')
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_fields', [
|
||||
'name' => $data['fields'][0]['name'],
|
||||
'type' => $data['fields'][0]['type'],
|
||||
'unit' => $data['fields'][0]['unit'],
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_fields', [
|
||||
'name' => $data['fields'][1]['name'],
|
||||
'type' => $data['fields'][1]['type'],
|
||||
'unit' => $data['fields'][1]['unit'],
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('azmayesh_types', [
|
||||
'name' => $data['name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user