Create templated workflows in draft status
MAILPOET-4264
This commit is contained in:
committed by
Veljko V
parent
25b9f3a876
commit
2bf59eab9a
@ -34,6 +34,7 @@ class CreateWorkflowFromTemplateController {
|
|||||||
throw UnexpectedValueException::create()->withMessage('Template not found.');
|
throw UnexpectedValueException::create()->withMessage('Template not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$workflow->setDraft();
|
||||||
$this->storage->createWorkflow($workflow);
|
$this->storage->createWorkflow($workflow);
|
||||||
return $workflow;
|
return $workflow;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use MailPoet\Automation\Engine\Utils\Json;
|
|||||||
class Workflow {
|
class Workflow {
|
||||||
public const STATUS_ACTIVE = 'active';
|
public const STATUS_ACTIVE = 'active';
|
||||||
public const STATUS_INACTIVE = 'inactive';
|
public const STATUS_INACTIVE = 'inactive';
|
||||||
|
public const STATUS_DRAFT = 'draft';
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $id;
|
private $id;
|
||||||
@ -55,6 +56,10 @@ class Workflow {
|
|||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDraft(): void {
|
||||||
|
$this->status = self::STATUS_DRAFT;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): DateTimeImmutable {
|
public function getCreatedAt(): DateTimeImmutable {
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,18 @@ class WorkflowsCreateFromTemplateTest extends AutomationTest {
|
|||||||
$countAfter = count($storage->getWorkflows());
|
$countAfter = count($storage->getWorkflows());
|
||||||
expect($countAfter)->equals($countBefore + 1);
|
expect($countAfter)->equals($countBefore + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWorkflowsCreatedFromTemplatesAreCreatedInDraftStatus(): void {
|
||||||
|
$storage = ContainerWrapper::getInstance()->get(WorkflowStorage::class);
|
||||||
|
$this->post(self::ENDPOINT_PATH, [
|
||||||
|
'json' => [
|
||||||
|
'name' => 'Testing workflow from template',
|
||||||
|
'template' => 'delayed-email-after-signup'
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$allWorkflows = $storage->getWorkflows();
|
||||||
|
$createdWorkflow = array_pop($allWorkflows);
|
||||||
|
expect($createdWorkflow->getStatus())->equals('draft');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user