Add name property to Step
[MAILPOET-4445]
This commit is contained in:
@@ -36,6 +36,7 @@ class UpdateStepsController {
|
||||
|
||||
return new Step(
|
||||
$data['id'],
|
||||
$data['name'] ?? null,
|
||||
$data['type'],
|
||||
$data['key'],
|
||||
$data['next_step_id'] ?? null,
|
||||
|
@@ -9,6 +9,9 @@ class Step {
|
||||
/** @var string */
|
||||
private $id;
|
||||
|
||||
/** @var ?string */
|
||||
private $name;
|
||||
|
||||
/** @var string */
|
||||
private $type;
|
||||
|
||||
@@ -23,12 +26,14 @@ class Step {
|
||||
|
||||
public function __construct(
|
||||
string $id,
|
||||
?string $name,
|
||||
string $type,
|
||||
string $key,
|
||||
?string $nextStepId = null,
|
||||
array $args = []
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->key = $key;
|
||||
$this->nextStepId = $nextStepId;
|
||||
@@ -39,6 +44,10 @@ class Step {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getType(): string {
|
||||
return $this->type;
|
||||
}
|
||||
@@ -62,6 +71,7 @@ class Step {
|
||||
public function toArray(): array {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'key' => $this->key,
|
||||
'next_step_id' => $this->nextStepId,
|
||||
|
@@ -170,6 +170,7 @@ class Workflow {
|
||||
foreach ($data as $step) {
|
||||
$steps[] = new Step(
|
||||
$step['id'],
|
||||
$step['name'] ?? null,
|
||||
$step['type'],
|
||||
$step['key'],
|
||||
$step['next_step_id'] ?? null,
|
||||
|
@@ -31,6 +31,7 @@ class WorkflowsPutEndpoint extends Endpoint {
|
||||
public static function getRequestSchema(): array {
|
||||
$step = Builder::object([
|
||||
'id' => Builder::string()->required(),
|
||||
'name' => Builder::string()->nullable(),
|
||||
'type' => Builder::string()->required(),
|
||||
'key' => Builder::string()->required(),
|
||||
'args' => Builder::object(),
|
||||
@@ -55,6 +56,7 @@ class WorkflowsPutEndpoint extends Endpoint {
|
||||
'steps' => array_map(function (Step $step) {
|
||||
return [
|
||||
'id' => $step->getId(),
|
||||
'name' => $step->getName(),
|
||||
'type' => $step->getType(),
|
||||
'key' => $step->getKey(),
|
||||
'next_step_id' => $step->getNextStepId(),
|
||||
|
@@ -78,6 +78,7 @@ class WorkflowBuilder {
|
||||
private function delayStep(?int $delay, string $delayType): Step {
|
||||
return new Step(
|
||||
$this->uniqueId(),
|
||||
null,
|
||||
Step::TYPE_ACTION,
|
||||
$this->delayAction->getKey(),
|
||||
null,
|
||||
@@ -91,6 +92,7 @@ class WorkflowBuilder {
|
||||
private function segmentSubscribedTriggerStep(?int $segmentId = null): Step {
|
||||
return new Step(
|
||||
$this->uniqueId(),
|
||||
null,
|
||||
Step::TYPE_TRIGGER,
|
||||
$this->segmentSubscribedTrigger->getKey(),
|
||||
null,
|
||||
@@ -103,6 +105,7 @@ class WorkflowBuilder {
|
||||
private function sendEmailActionStep(): Step {
|
||||
return new Step(
|
||||
$this->uniqueId(),
|
||||
__('Send email', 'mailpoet'),
|
||||
Step::TYPE_ACTION,
|
||||
$this->sendEmailAction->getKey(),
|
||||
null,
|
||||
|
@@ -16,7 +16,7 @@ class DelayActionTest extends \MailPoetTest {
|
||||
*/
|
||||
public function testItCalculatesDelayTypesCorrectly(int $delay, string $type, int $expectation) {
|
||||
|
||||
$step = new Step("1", 'core:delay', 'core:delay', 'next-step', [
|
||||
$step = new Step("1", null, 'core:delay', 'core:delay', 'next-step', [
|
||||
'delay' => $delay,
|
||||
'delay_type' => $type,
|
||||
]);
|
||||
@@ -81,7 +81,7 @@ class DelayActionTest extends \MailPoetTest {
|
||||
*/
|
||||
public function testDelayActionInvalidatesOutsideOfBoundaries(int $delay, bool $expectation) {
|
||||
|
||||
$step = new Step("1", 'core:delay', 'core:delay', 'next-step', [
|
||||
$step = new Step("1", null,'core:delay', 'core:delay', 'next-step', [
|
||||
'delay' => $delay,
|
||||
'delay_type' => "HOURS",
|
||||
]);
|
||||
|
@@ -60,7 +60,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$this->segmentSubject = $this->diContainer->get(SegmentSubject::class);
|
||||
|
||||
$this->email = (new Newsletter())->withAutomationType()->create();
|
||||
$this->step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $this->email->getId()]);
|
||||
$this->step = new Step('step-id', null,Step::TYPE_ACTION, 'step-key', null, ['email_id' => $this->email->getId()]);
|
||||
$this->workflow = new Workflow('test-workflow', []);
|
||||
}
|
||||
|
||||
@@ -78,13 +78,13 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItIsNotValidIfStepHasNoEmail(): void {
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, []);
|
||||
$step = new Step('step-id', null,Step::TYPE_ACTION, 'step-key', null, []);
|
||||
expect($this->action->isValid($this->getSubjects(), $step, $this->workflow))->false();
|
||||
}
|
||||
|
||||
public function testItRequiresAutomationEmailType(): void {
|
||||
$newsletter = (new Newsletter())->withPostNotificationsType()->create();
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $newsletter->getId()]);
|
||||
$step = new Step('step-id', null, Step::TYPE_ACTION, 'step-key', null, ['email_id' => $newsletter->getId()]);
|
||||
expect($this->action->isValid($this->getSubjects(), $step, $this->workflow))->false();
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null, Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
@@ -119,7 +119,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null, Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
@@ -151,7 +151,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null, Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
@@ -180,7 +180,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null,Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
@@ -218,7 +218,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null,Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
@@ -247,7 +247,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
||||
$subjects = $this->getLoadedSubjects($subscriber, $segment);
|
||||
$email = (new Newsletter())->withAutomationType()->create();
|
||||
|
||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$step = new Step('step-id', null, Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||
$workflow = new Workflow('some-workflow', [$step]);
|
||||
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||
|
||||
|
Reference in New Issue
Block a user