1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace Tests\Feature\API;
- use App\Models\Plan;
- use Tests\Feature\TestCase;
- class PlanTest extends TestCase
- {
- public function test_create_plan(): void
- {
- $form = Plan::factory()->make();
- $response = $this->post(route('plan.store'), $form->toArray());
- $response->assertStatus(201);
- }
- public function test_plan_list()
- {
- Plan::factory(30)->create();
- $response = $this->get(route('plan.index'));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- '*' => [
- 'id',
- 'title',
- 'requirement_total',
- 'project_total',
- 'begin',
- 'end',
- 'description',
- ]
- ]
- ]);
- }
- public function test_plan_show()
- {
- $plan = Plan::factory()->create();
- $response = $this->get(route('plan.show', ['plan' => $plan->id]));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- 'id',
- 'title',
- 'requirement_total',
- 'asset_id',
- 'parent_id',
- 'project_total',
- 'begin',
- 'end',
- 'description',
- ]
- ]);
- }
- public function test_plan_update(): void
- {
- $plan = Plan::factory()->create();
- $form = Plan::factory()->make();
- $response = $this->put(route('plan.update', ['plan' => $plan->id]), $form->toArray());
- $response->assertStatus(204);
- $newAsset = Plan::find($plan->id);
- $this->assertEquals($form->name, $newAsset->name);
- }
- public function test_plan_delete(): void
- {
- $plan = Plan::factory()->create();
- $response = $this->delete(route('plan.destroy', ['plan' => $plan->id]));
- $response->assertStatus(204);
- $this->assertNull(Plan::find($plan->id));
- }
- }
|