public function test_it_finishes_a_todo()
 {
     $todo = Factory::create(\App\Umbrella\Todo\Todo::class);
     $todolistRepository = $this->mockTodoRepository();
     $todolistRepository->shouldReceive('byId')->once()->andReturn($todo);
     $todolistRepository->shouldReceive('update')->once();
     $todoApplicationService = new TodoApplicationService();
     $todoApplicationService->finishTodo($todo->id);
 }
Ejemplo n.º 2
0
 /**
  * @param $todoId
  */
 public function activate($todoId)
 {
     $todoApplicationService = new TodoApplicationService();
     $todo = $this->todoRepository->byId($todoId);
     if (Gate::denies('delete-todo', $todo)) {
         abort(403);
     }
     $todoApplicationService->reActivateTodo($todoId);
 }
Ejemplo n.º 3
0
 /**
  * @param AddTodoRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function createTodo(AddTodoRequest $request)
 {
     $name = $request->get('name');
     $todoListId = $request->get('todo_list_id');
     $todoList = $this->todolistRepository->byId($todoListId);
     $todoApplicationService = new TodoApplicationService();
     $todo = $todoApplicationService->create($name, $todoList);
     if ($request->wantsJson()) {
         return $todo;
     }
     return redirect(route('todolist.show', $todoListId));
 }