Example #1
0
 public function whenICreateAGoalWith_Tasks($count)
 {
     $command = new CreateGoal('Foo');
     foreach (range(1, $count) as $i) {
         $command->addTask("Task {$i}");
     }
     $this->events = $this->service->handle($command);
 }
Example #2
0
 public function handleCreateGoal(CreateGoal $command)
 {
     $goalId = $this->uid->generate('Goal');
     $events = [new GoalCreated($goalId, $command->getName())];
     if ($command->getNotesContent()) {
         $events[] = new GoalNotesChanged($goalId, $command->getNotesContent());
     }
     if ($command->getRating()) {
         $events[] = new GoalRated($goalId, $command->getRating());
     }
     foreach ($command->getAllTasks() as $taskDescription) {
         $events[] = new TaskAdded($this->uid->generate('Task'), $goalId, $taskDescription);
     }
     return $events;
 }