Files
piratepoet/mailpoet/tests/integration/REST/Automation/Workflows/WorkflowsPostTest.php
Jan Jakes adf6dd3ce9 Add schema for workflow post endpoint
[MAILPOET-4207]
2022-04-20 15:30:50 +02:00

47 lines
1.3 KiB
PHP

<?php declare(strict_types = 1);
namespace MailPoet\REST\Automation\Workflows;
require_once __DIR__ . '/../AutomationTest.php';
use MailPoet\REST\Automation\AutomationTest;
class WorkflowsPostTest extends AutomationTest {
private const ENDPOINT_PATH = '/mailpoet/v1/automation/workflows';
public function testGuestNotAllowed(): void {
wp_set_current_user(0);
$data = $this->post(self::ENDPOINT_PATH, ['json' => ['name' => 'Testing workflow', 'steps' => []]]);
$this->assertSame([
'code' => 'rest_forbidden',
'message' => 'Sorry, you are not allowed to do that.',
'data' => ['status' => 401],
], $data);
}
public function testCreateWorkflow(): void {
$data = $this->post(self::ENDPOINT_PATH, [
'json' => [
'name' => 'Testing workflow',
'steps' => [
'e6d193766b9ecd1e' => [
'id' => 'e6d193766b9ecd1e',
'type' => 'action',
'key' => 'core:wait',
'args' => ['seconds' => 60],
],
'0d618edf689909ef' => [
'id' => '0d618edf689909ef',
'type' => 'trigger',
'key' => 'mailpoet:segment:subscribed',
'next_step_id' => 'e6d193766b9ecd1e',
],
],
],
]);
$this->assertSame(['data' => null], $data);
}
}