Ejemplo n.º 1
0
 /**
  * @test
  */
 public function it_adds_a_deadline_to_todo()
 {
     $todoId = TodoId::generate();
     $userId = UserId::generate();
     $deadline = TodoDeadline::fromString('2047-12-31 12:00:00', '2047-12-01 12:00:00');
     $todo = Todo::post('Do something tomorrow', $userId, $todoId);
     $this->assertNull($todo->deadline());
     $todo->addDeadline($userId, $deadline);
     $events = $this->popRecordedEvent($todo);
     $this->assertEquals(2, count($events));
     $this->assertInstanceOf(DeadlineWasAddedToTodo::class, $events[1]);
     $expectedPayload = ['todo_id' => $todoId->toString(), 'user_id' => $userId->toString(), 'deadline' => $deadline->toString()];
     $this->assertEquals($expectedPayload, $events[1]->payload());
     return $todo;
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function it_throws_an_exception_when_marking_a_completed_todo_as_expired()
 {
     $todoId = TodoId::generate();
     $userId = UserId::generate();
     $deadline = TodoDeadline::fromString('2047-12-31 12:00:00');
     $todo = Todo::post('Do something fun', $userId, $todoId);
     $todo->addDeadline($userId, $deadline);
     $todo->markAsDone();
     $this->setExpectedException(TodoNotOpen::class, 'Tried to expire todo with status done.');
     $todo->markAsExpired();
 }
Ejemplo n.º 3
0
 /**
  * @test
  * @return Todo
  */
 public function it_adds_a_reminder_to_todo()
 {
     $todoId = TodoId::generate();
     $userId = UserId::generate();
     $reminder = TodoReminder::fromString('2047-12-31 12:00:00');
     $todo = Todo::post('Do something tomorrow', $userId, $todoId);
     $this->popRecordedEvent($todo);
     $this->assertNull($todo->reminder());
     $todo->addReminder($userId, $reminder);
     $events = $this->popRecordedEvent($todo);
     $this->assertCount(1, $events);
     $this->assertInstanceOf(ReminderWasAddedToTodo::class, $events[0]);
     $expectedPayload = ['todo_id' => $todoId->toString(), 'user_id' => $userId->toString(), 'reminder' => $reminder->toString()];
     $this->assertEquals($expectedPayload, $events[0]->payload());
     return $todo;
 }
Ejemplo n.º 4
0
 /**
  * @param string $text
  * @param TodoId $todoId
  * @return Todo
  */
 public function postTodo($text, TodoId $todoId)
 {
     return Todo::post($text, $this->userId(), $todoId);
 }