Pass full step map to automation workflow so it can be validated
[MAILPOET-4629]
This commit is contained in:
@@ -44,7 +44,7 @@ class Workflow {
|
||||
/** @var array<string, Step> */
|
||||
private $steps;
|
||||
|
||||
/** @param Step[] $steps */
|
||||
/** @param array<string, Step> $steps */
|
||||
public function __construct(
|
||||
string $name,
|
||||
array $steps,
|
||||
@@ -53,11 +53,8 @@ class Workflow {
|
||||
int $versionId = null
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->steps = [];
|
||||
$this->steps = $steps;
|
||||
$this->author = $author;
|
||||
foreach ($steps as $step) {
|
||||
$this->steps[$step->getId()] = $step;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$this->id = $id;
|
||||
|
@@ -38,9 +38,9 @@ class WorkflowBuilder {
|
||||
$nextSteps
|
||||
);
|
||||
$nextSteps = [new NextStep($step->getId())];
|
||||
$steps[] = $step;
|
||||
$steps[$step->getId()] = $step;
|
||||
}
|
||||
$steps[] = new Step('root', 'root', 'core:root', [], $nextSteps);
|
||||
$steps['root'] = new Step('root', 'root', 'core:root', [], $nextSteps);
|
||||
$steps = array_reverse($steps);
|
||||
return new Workflow(
|
||||
$name,
|
||||
|
@@ -154,7 +154,7 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
||||
public function testItStoresWorkflowRunAndStepIdsCorrectly() {
|
||||
$testAction = $this->getRegisteredTestAction();
|
||||
$actionStep = new Step('action-step-id', Step::TYPE_ACTION, $testAction->getKey(), [], []);
|
||||
$workflow = new Workflow('test_workflow', [$actionStep], new \WP_User());
|
||||
$workflow = new Workflow('test_workflow', [$actionStep->getId() => $actionStep], new \WP_User());
|
||||
$workflowId = $this->workflowStorage->createWorkflow($workflow);
|
||||
// Reload to get additional data post-save
|
||||
$workflow = $this->workflowStorage->getWorkflow($workflowId);
|
||||
@@ -240,7 +240,7 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
||||
}
|
||||
$testAction = $this->getRegisteredTestAction($callback);
|
||||
$actionStep = new Step('action-step-id', Step::TYPE_ACTION, $testAction->getKey(), [], []);
|
||||
$workflow = new Workflow('test_workflow', [$actionStep], new \WP_User());
|
||||
$workflow = new Workflow('test_workflow', [$actionStep->getId() => $actionStep], new \WP_User());
|
||||
$workflowId = $this->workflowStorage->createWorkflow($workflow);
|
||||
// Reload to get additional data post-save
|
||||
$workflow = $this->workflowStorage->getWorkflow($workflowId);
|
||||
|
@@ -107,7 +107,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
@@ -129,7 +129,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
@@ -161,7 +161,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
@@ -190,7 +190,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
@@ -228,7 +228,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
@@ -257,7 +257,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', ['email_id' => $email->getId()], []);
|
||||
$workflow = new Workflow('some-workflow', [$step], new \WP_User());
|
||||
$workflow = new Workflow('some-workflow', [$step->getId() => $step], new \WP_User());
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||
|
Reference in New Issue
Block a user