make(); $form->whitelist = [ Auth::id(), ]; $response = $this->postJson(route('task.store'), $form->toArray()); $response->assertStatus(201); } public function test_task_list() { Task::factory(30)->create(); $response = $this->get(route('task.index')); $response->assertStatus(200) ->assertJsonStructure([ 'data' => [ '*' => [ "id", "name", "parent_id", "begin", "end", "status", "assign_to", "created_by", ] ] ]); } public function test_task_show(): void { $task = Task::factory()->create(); $response = $this->get(route('task.show', ['task' => $task->id])); $response->assertStatus(200) ->assertJsonStructure([ 'data' => [ "id", "name", "project_id", "project", "requirement_id", "naming_rule_id", "parent_id", "task_type", "doc_stage", "doc_type", "status", "assign", "description", "begin", "end", "mailto", "email_subject", "acl", "whitelist", "closed_by", "closed_at", "canceled_by", "canceled_at", "approve_by", "approve_at", "finished_by", "finished_at", "review_by", "review_at", "created_by", "custom_fields", "created_at", "updated_at" ] ]); } public function test_task_update(): void { $task = Task::factory()->create(); $form = Task::factory()->make(); $form->whitelist = [ Auth::id(), ]; $response = $this->putJson(route('task.update', ['task' => $task->id]), $form->toArray()); $response->assertStatus(204); $newTask = Task::find($task->id); $this->assertEquals($form->name, $newTask->name); } public function test_task_delete(): void { $task = Task::factory()->create(); $response = $this->delete(route('task.destroy', ['task' => $task->id])); $response->assertStatus(204); $this->assertNull(Task::find($task->id)); } }