CustomFieldTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Tests\Feature\API;
  3. use App\Models\CustomField;
  4. use Illuminate\Foundation\Testing\RefreshDatabase;
  5. use Illuminate\Foundation\Testing\WithFaker;
  6. use Tests\Feature\TestCase;
  7. class CustomFieldTest extends TestCase
  8. {
  9. public function test_asset_group_list()
  10. {
  11. CustomField::factory(30)->create();
  12. $response = $this->get(route('custom-field.index'), [
  13. 'group' => config("custom-field.groups")[array_rand(config("custom-field.groups"))]
  14. ]);
  15. $response->assertStatus(200)
  16. ->assertJsonStructure([
  17. 'data' => [
  18. '*' => [
  19. 'id',
  20. 'key',
  21. 'group',
  22. 'label',
  23. 'options',
  24. 'type',
  25. 'required',
  26. ]
  27. ]
  28. ]);
  29. }
  30. public function test_custom_field_save(): void
  31. {
  32. $form = CustomField::factory()->make();
  33. $response = $this->postJson(route('custom-field.store'), $form->toArray());
  34. $response->assertStatus(201);
  35. }
  36. public function test_custom_groups(): void
  37. {
  38. $response = $this->get(route('custom-field.groups'));
  39. $response->assertStatus(200)->assertJsonCount(count(config("custom-field.groups")), "data");
  40. }
  41. }