/**
  * @return UserId
  */
 public function assigneeId()
 {
     if (is_null($this->assigneeId)) {
         $this->assigneeId = UserId::fromString($this->payload['assignee_id']);
     }
     return $this->assigneeId;
 }
 /**
  * @return UserId
  */
 public function userId()
 {
     if (!$this->userId) {
         $this->userId = UserId::fromString($this->payload['user_id']);
     }
     return $this->userId;
 }
 /**
  * @return UserId
  */
 public function userId()
 {
     if (is_null($this->userId)) {
         $this->userId = UserId::fromString($this->aggregateId());
     }
     return $this->userId;
 }
Beispiel #4
0
 /**
  * @return UserId
  */
 public function assigneeId()
 {
     return UserId::fromString($this->payload['assignee_id']);
 }
Beispiel #5
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();
 }
Beispiel #6
0
 /**
  * @test
  * @expectedException \Prooph\ProophessorDo\Model\Todo\Exception\InvalidDeadline
  * @depends it_adds_a_deadline_to_todo
  */
 public function it_throws_an_exception_if_user_is_not_the_assignee(Todo $todo)
 {
     $todo->addDeadline(UserId::generate(), TodoDeadline::fromString('2047-12-11 12:00:00'));
 }
 /**
  * @param UserId $userId
  * @return UserNotFound
  */
 public static function withUserId(UserId $userId)
 {
     return new self(sprintf('User with id %s cannot be found.', $userId->toString()));
 }
 /**
  * @param UserId $user
  * @param UserId $assigneeId
  * @return InvalidDeadline
  */
 public static function userIsNotAssignee(UserId $user, UserId $assigneeId)
 {
     return new self(sprintf('User %s tried to add a deadline to the todo owned by %s', $user->toString(), $assigneeId->toString()));
 }
 /**
  * @return UserId
  */
 public function userId()
 {
     return UserId::fromString($this->payload['user_id']);
 }
Beispiel #10
0
 /**
  * @test
  * @param Todo $todo
  * @depends it_adds_a_reminder_to_todo
  */
 public function it_throws_an_exception_if_user_who_adds_reminder_is_not_the_assignee(Todo $todo)
 {
     $this->setExpectedException(InvalidReminder::class);
     $todo->addReminder(UserId::generate(), TodoReminder::fromString('2047-12-11 12:00:00'));
 }
 /**
  * @param UserId $userId
  * @return User
  */
 public function get(UserId $userId)
 {
     return $this->getAggregateRoot($userId->toString());
 }
     $textCount = count($texts);
     $randIndex = rand(0, --$textCount);
     return $texts[$randIndex];
 }
 function calcCommandAverage($duration)
 {
     $commandCount = NUMBER_OF_USERS * NUMBER_OF_TODO_PER_USER + NUMBER_OF_USERS;
     return $duration / $commandCount;
 }
 $container = (require 'config/container.php');
 $commandBus = $container->get(\Prooph\ServiceBus\CommandBus::class);
 $openTodos = [];
 $stopWatch = new Stopwatch();
 $stopWatch->start('generate_model');
 for ($i = 1; $i <= NUMBER_OF_USERS; $i++) {
     $userId = UserId::generate();
     $username = getUserName($i);
     $email = $username . '@acme.com';
     $commandBus->dispatch(RegisterUser::withData($userId->toString(), $username, $email));
     for ($j = 0; $j < NUMBER_OF_TODO_PER_USER; $j++) {
         $todoId = TodoId::generate();
         $commandBus->dispatch(PostTodo::forUser($userId->toString(), randTodoText(), $todoId->toString()));
         $openTodos[] = $todoId->toString();
     }
     echo "User: "******"(" . $userId->toString() . ") was registered\n";
 }
 $generatedEvent = $stopWatch->stop('generate_model');
 echo "\nModel generated in: " . $generatedEvent->getDuration() . " ms\n";
 echo "Command execution average: " . calcCommandAverage($generatedEvent->getDuration()) . " ms\n";
 echo "\nGoing to close todo randomly now\n";
 foreach ($openTodos as $openTodoId) {
Beispiel #13
0
 /**
  * @param UserId $other
  * @return bool
  */
 public function sameValueAs(UserId $other)
 {
     return $this->toString() === $other->toString();
 }
Beispiel #14
0
 /**
  * @return string representation of the unique identifier of the aggregate root
  */
 protected function aggregateId()
 {
     return $this->userId->toString();
 }