/**
  * @param WorkflowId $workflowId
  * @param Process $process
  * @param Task $task
  * @return TaskWasAddedToProcess
  */
 public static function record(WorkflowId $workflowId, Process $process, Task $task)
 {
     $event = self::occur($workflowId->toString(), ['process_id' => $process->id()->toString(), 'task_id' => $task->id()->toString()]);
     $event->workflowId = $workflowId;
     $event->processId = $process->id();
     $event->taskId = $task->id();
     return $event;
 }
 /**
  * @test
  */
 function it_can_be_reconstituted_with_a_task_list()
 {
     $task1 = TaskId::generate();
     $task2 = TaskId::generate();
     $process = Process::withTaskList([$task1, $task2], ProcessId::generate(), ProcessType::linearMessaging());
     $this->assertTrue($task1->equals($process->tasks()[0]));
     $this->assertTrue($task2->equals($process->tasks()[1]));
     $this->assertTrue(ProcessType::linearMessaging()->equals($process->type()));
 }
 /**
  * @param Process $process
  * @param Workflow $workflow
  * @return ProcessWasAddedToWorkflow
  */
 public static function record(Process $process, Workflow $workflow)
 {
     $event = self::occur($workflow->workflowId()->toString(), ['process_id' => $process->id()->toString(), 'process_type' => $process->type()->toString(), 'task_list' => array_map(function (TaskId $taskId) {
         $taskId->toString();
     }, $process->tasks())]);
     $event->workflowId = $workflow->workflowId();
     $event->processId = $process->id();
     $event->processType = $process->type();
     $event->tasks = $process->tasks();
     return $event;
 }
 /**
  * @param ProcessWasAddedToWorkflow $event
  */
 protected function whenProcessWasAddedToWorkflow(ProcessWasAddedToWorkflow $event)
 {
     $this->processList[] = Process::withTaskList($event->tasks(), $event->processId(), $event->processType());
 }
 /**
  * @param Workflow\Process $process
  * @return array
  */
 private function translateToProcessingProcess(Workflow\Process $process)
 {
     $tasks = [];
     foreach ($process->tasks() as $taskId) {
         $tasks[] = $this->translateToProcessingTask($taskId);
     }
     return ['process_type' => $process->type()->toString(), 'tasks' => $tasks];
 }
 /**
  * @param Process $other
  * @return bool
  */
 public function sameAs(Process $other)
 {
     return $this->processId->equals($other->id());
 }