1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace Tests\Feature\API;
- use App\Models\CustomField;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\Feature\TestCase;
- class CustomFieldTest extends TestCase
- {
- public function test_asset_group_list()
- {
- CustomField::factory(30)->create();
- $response = $this->get(route('custom-field.index'), [
- 'group' => config("custom-field.groups")[array_rand(config("custom-field.groups"))]
- ]);
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- '*' => [
- 'id',
- 'key',
- 'group',
- 'label',
- 'options',
- 'type',
- 'required',
- ]
- ]
- ]);
- }
- public function test_custom_field_save(): void
- {
- $form = CustomField::factory()->make();
- $response = $this->postJson(route('custom-field.store'), $form->toArray());
- $response->assertStatus(201);
- }
- public function test_custom_groups(): void
- {
- $response = $this->get(route('custom-field.groups'));
- $response->assertStatus(200)->assertJsonCount(count(config("custom-field.groups")), "data");
- }
- }
|