PlanTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Tests\Feature\API;
  3. use App\Models\Plan;
  4. use Tests\Feature\TestCase;
  5. class PlanTest extends TestCase
  6. {
  7. public function test_create_plan(): void
  8. {
  9. $form = Plan::factory()->make();
  10. $response = $this->post(route('plan.store'), $form->toArray());
  11. $response->assertStatus(201);
  12. }
  13. public function test_asset_group_list()
  14. {
  15. Plan::factory(30)->create();
  16. $response = $this->get(route('plan.index'));
  17. $response->assertStatus(200)
  18. ->assertJsonStructure([
  19. 'data' => [
  20. '*' => [
  21. 'id',
  22. 'title',
  23. 'requirement_total',
  24. 'project_total',
  25. 'begin',
  26. 'end',
  27. 'description',
  28. ]
  29. ]
  30. ]);
  31. }
  32. public function test_plan_update(): void
  33. {
  34. $plan = Plan::factory()->create();
  35. $form = Plan::factory()->make();
  36. $response = $this->put(route('plan.update', ['plan' => $plan->id]), $form->toArray());
  37. $response->assertStatus(204);
  38. $newAsset = Plan::find($plan->id);
  39. $this->assertEquals($form->name, $newAsset->name);
  40. }
  41. public function test_plan_delete(): void
  42. {
  43. $plan = Plan::factory()->create();
  44. $response = $this->delete(route('plan.destroy', ['plan' => $plan->id]));
  45. $response->assertStatus(204);
  46. $this->assertNull(Plan::find($plan->id));
  47. }
  48. }