/**
  * @return TodoReminder
  */
 public function reminder()
 {
     if (!$this->reminder) {
         $this->reminder = TodoReminder::fromString($this->payload['reminder'], TodoReminderStatus::OPEN);
     }
     return $this->reminder;
 }
 /**
  * @return TodoReminder
  */
 public function reminder()
 {
     if (!$this->reminder) {
         $this->reminder = TodoReminder::fromString($this->payload['reminder'], $this->payload['reminder_status']);
     }
     return $this->reminder;
 }
 public function it_returns_a_new_reminder_with_status_closed_when_closed()
 {
     $reminder = TodoReminder::fromString('2047-02-01 10:00:00', TodoReminderStatus::OPEN);
     $reminderClosed = $reminder->close();
     $this->assertNotEquals($reminder, $reminderClosed);
     $this->assertFalse($reminderClosed->isOpen());
 }
示例#4
0
 /**
  * @test
  * @dataProvider getReminders
  *
  * @param $reminder
  * @param $inThePast
  */
 public function it_correctly_validates_the_reminder($reminder, $inThePast)
 {
     $reminder = TodoReminder::fromString($reminder);
     $reminderInThePast = $reminder->isInThePast();
     if ($inThePast) {
         $this->assertTrue($reminderInThePast);
     } else {
         $this->assertFalse($reminderInThePast);
     }
 }
 /**
  * @return TodoReminder
  */
 public function reminder()
 {
     return TodoReminder::fromString($this->payload['reminder'], $this->payload['reminder_status']);
 }
<?php

/**
 * This script looks for todos with open reminders and reminds the assignees
 */
namespace {
    use Prooph\ProophessorDo\Model\Todo\Command\RemindTodoAssignee;
    use Prooph\ProophessorDo\Model\Todo\TodoId;
    use Prooph\ProophessorDo\Model\Todo\TodoReminder;
    use Prooph\ProophessorDo\Projection\Todo\TodoReminderFinder;
    use Prooph\ServiceBus\CommandBus;
    chdir(dirname(__DIR__));
    // Setup autoloading
    require 'vendor/autoload.php';
    $container = (require 'config/container.php');
    $commandBus = $container->get(CommandBus::class);
    $todoReminderFinder = $container->get(TodoReminderFinder::class);
    $todoReminder = $todoReminderFinder->findOpen();
    if (!$todoReminder) {
        echo "Nothing to do. Exiting.\n";
        exit;
    }
    foreach ($todoReminder as $reminder) {
        echo "Send reminder for Todo with id {$reminder->todo_id}.\n";
        $commandBus->dispatch(RemindTodoAssignee::forTodo(TodoId::fromString($reminder->todo_id), TodoReminder::fromString($reminder->reminder, $reminder->status)));
    }
    echo "Done!\n";
}
示例#7
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);
 }
示例#8
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'));
 }
 /**
  * @return TodoReminder
  */
 public function reminder()
 {
     return TodoReminder::fromString($this->payload['reminder'], TodoReminderStatus::OPEN);
 }