/**
  * @param Todo $todo
  * @param TodoReminder $reminder
  * @return bool
  */
 private function reminderShouldBeProcessed(Todo $todo, TodoReminder $reminder)
 {
     // drop command, wrong reminder
     if (!$todo->reminder()->equals($reminder)) {
         return false;
     }
     // drop command, reminder is closed
     if (!$reminder->isOpen()) {
         return false;
     }
     // drop command, reminder is in future
     if ($reminder->isInTheFuture()) {
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * @test
  * @return Todo $todo
  * @depends it_marks_an_open_todo_as_expired
  */
 public function it_unmarks_an_expired_todo_when_deadline_is_added(Todo $todo)
 {
     $userId = $todo->assigneeId();
     $deadline = TodoDeadline::fromString('1 day');
     $todo->addDeadline($userId, $deadline);
     $events = $this->popRecordedEvent($todo);
     $this->assertEquals(2, count($events));
     $this->assertInstanceOf(TodoWasUnmarkedAsExpired::class, $events[1]);
     return $todo;
 }
Пример #3
0
 /**
  * @test
  * @expectedException \Prooph\ProophessorDo\Model\Todo\Exception\TodoNotOpen
  * @depends it_adds_a_deadline_to_todo
  */
 public function it_throws_an_exception_if_todo_is_closed(Todo $todo)
 {
     $todo->markAsDone();
     $todo->addDeadline($todo->assigneeId(), TodoDeadline::fromString('2047-12-11 12:00:00'));
 }
Пример #4
0
 /**
  * @param TodoStatus $status
  * @param Todo $todo
  * @return TodoNotOpen
  */
 public static function triedStatus(TodoStatus $status, Todo $todo)
 {
     return new self(sprintf('Tried to change status of Todo %s to %s. But Todo is not marked as open!', $todo->todoId()->toString(), $status->toString()));
 }
Пример #5
0
 /**
  * @param TodoStatus $status
  * @param Todo $todo
  * @return CannotReopenTodo
  */
 public static function notMarkedDone(Todo $todo)
 {
     return new self(sprintf('Tried to reopen status of Todo %s. But Todo is not marked as done!', $todo->todoId()->toString()));
 }
Пример #6
0
 /**
  * @test
  * @param Todo $todo
  * @depends it_adds_a_reminder_to_todo
  */
 public function it_throws_an_exception_if_todo_is_closed_while_setting_a_reminder(Todo $todo)
 {
     $todo->markAsDone();
     $this->setExpectedException(TodoNotOpen::class);
     $todo->addReminder($todo->assigneeId(), TodoReminder::fromString('2047-12-11 12:00:00'));
 }
Пример #7
0
 /**
  * @param string $text
  * @param TodoId $todoId
  * @return Todo
  */
 public function postTodo($text, TodoId $todoId)
 {
     return Todo::post($text, $this->userId(), $todoId);
 }