public function test_it_deletes_a_todo_item() { $todo = Factory::create(\App\Umbrella\Todo\Todo::class); $todolistRepository = $this->mockTodoRepository(); $todolistRepository->shouldReceive('deleteById')->once(); $todoApplicationService = new TodoApplicationService(); $todoApplicationService->delete($todo->id); }
/** * @param $todoId * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function delete($todoId) { $todoApplicationService = new TodoApplicationService(); $todo = $this->todoRepository->byId($todoId); $todoListId = $todo->todolist->id; if (Gate::denies('delete-todo', $todo)) { abort(403); } $todoApplicationService->delete($todoId); return redirect(route('todolist.show', $todoListId)); }