1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace Tests\Feature\API;
- use App\Models\Asset;
- use App\Models\Plan;
- use App\Models\Project;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Tests\Feature\TestCase;
- class ProjectTest extends TestCase
- {
- public function test_project_list()
- {
- Project::factory(30)->create();
- $response = $this->get(route('project.index'));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- '*' => [
- 'id',
- 'name',
- 'code',
- 'status',
- 'const',
- 'begin',
- 'end',
- 'available_days',
- ]
- ]
- ]);
- }
- public function test_project_create(): void
- {
- $form = Project::factory()->make();
- $form->whitelist = [
- 1
- ];
- $form->plans = [
- Plan::factory()->create()->id,
- Plan::factory()->create()->id,
- ];
- $form->assets = [
- Asset::factory()->create()->id,
- Asset::factory()->create()->id,
- ];
- $response = $this->post(route('project.store'), $form->toArray());
- $response->assertStatus(201);
- }
- }
|