Refactor WorkflowOnHoldController and improve tests

Refactored WorkflowOnHoldController to remove dependencies and improve redirect handling. Updated test cases to use PHPUnit instead of KernelTestCase and mock proper dependencies. Added relationship handling in EntityWorkflowStep to manage EntityWorkflowStepHold instances accurately.
This commit is contained in:
2024-09-06 13:51:07 +02:00
parent ad94310981
commit 49ad25b4c8
4 changed files with 99 additions and 77 deletions

View File

@@ -455,4 +455,13 @@ class EntityWorkflowStep
}
}
}
public function addOnHold(EntityWorkflowStepHold $onHold): self
{
if (!$this->holdsOnStep->contains($onHold)) {
$this->holdsOnStep->add($onHold);
}
return $this;
}
}

View File

@@ -32,7 +32,10 @@ class EntityWorkflowStepHold implements TrackCreationInterface
#[ORM\JoinColumn(nullable: false)]
private EntityWorkflowStep $step, #[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: false)]
private User $byUser) {}
private User $byUser)
{
$step->addOnHold($this);
}
public function getId(): ?int
{