/** * @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(); }
/** * @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')); }
/** * @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')); }
$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) {