Files
piratepoet/mailpoet/tests/integration/REST/Automation/Workflows/WorkflowsCreateFromTemplateTest.php
John Oleksowicz 2bf59eab9a Create templated workflows in draft status
MAILPOET-4264
2022-06-08 13:14:11 +02:00

41 lines
1.4 KiB
PHP

<?php declare(strict_types = 1);
namespace MailPoet\REST\Automation\Workflows;
require_once __DIR__ . '/../AutomationTest.php';
use MailPoet\Automation\Engine\Storage\WorkflowStorage;
use MailPoet\DI\ContainerWrapper;
use MailPoet\REST\Automation\AutomationTest;
class WorkflowsCreateFromTemplateTest extends AutomationTest {
private const ENDPOINT_PATH = '/mailpoet/v1/automation/workflows/create-from-template';
public function testCreateWorkflowFromTemplate(): void {
$storage = ContainerWrapper::getInstance()->get(WorkflowStorage::class);
$countBefore = count($storage->getWorkflows());
$this->post(self::ENDPOINT_PATH, [
'json' => [
'name' => 'Testing workflow from template',
'template' => 'delayed-email-after-signup'
],
]);
$countAfter = count($storage->getWorkflows());
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');
}
}