Exemple #1
0
 /**
  * @return Todo
  */
 private function todoWithReminderInThePast()
 {
     $userId = UserId::generate();
     $todoId = TodoId::generate();
     $reminder = TodoReminder::fromString('2000-12-11 12:00:00', TodoReminderStatus::OPEN);
     $events = [TodoWasPosted::byUser($userId, 'test', $todoId, TodoStatus::open()), ReminderWasAddedToTodo::byUserToDate($todoId, $userId, $reminder)];
     return $this->reconstituteAggregateFromHistory(Todo::class, $events);
 }
Exemple #2
0
 /**
  * @param UserId $userId
  * @param TodoReminder $reminder
  * @return void
  * @throws Exception\InvalidReminder
  */
 public function addReminder(UserId $userId, TodoReminder $reminder)
 {
     if (!$this->assigneeId()->sameValueAs($userId)) {
         throw Exception\InvalidReminder::userIsNotAssignee($userId, $this->assigneeId());
     }
     if ($reminder->isInThePast()) {
         throw Exception\InvalidReminder::reminderInThePast($reminder);
     }
     if ($this->status->isDone()) {
         throw Exception\TodoNotOpen::triedToAddReminder($reminder, $this->status);
     }
     $this->recordThat(ReminderWasAddedToTodo::byUserToDate($this->todoId, $this->assigneeId, $reminder));
 }