12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?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_asset_group_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_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));
- }
- }
|