Add consisten steps map rule for workflow validation

[MAILPOET-4629]
This commit is contained in:
Jan Jakes
2022-09-14 15:11:36 +02:00
committed by David Remer
parent 0aa4cd4863
commit 11a711e42c
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?php declare(strict_types = 1);
namespace MailPoet\Automation\Engine\Validation\WorkflowRules;
require_once __DIR__ . '/WorkflowRuleTest.php';
use MailPoet\Automation\Engine\Data\Workflow;
use MailPoet\Automation\Engine\Exceptions\UnexpectedValueException;
use MailPoet\Automation\Engine\Validation\WorkflowGraph\WorkflowWalker;
class ConsistentStepMapRuleTest extends WorkflowRuleTest {
public function testItDetectsWrongKeyValuePair(): void {
$workflow = $this->make(Workflow::class, ['getSteps' => [
'root' => $this->createStep('a'),
]]);
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('Invalid workflow structure: TODO');
(new WorkflowWalker())->walk($workflow, [new ConsistentStepMapRule()]);
}
public function testItPassesWithCorrectKeyValuePair(): void {
$workflow = $this->make(Workflow::class, ['getSteps' => [
'root' => $this->createStep('root'),
]]);
(new WorkflowWalker())->walk($workflow, [new ConsistentStepMapRule()]);
// no exception thrown
}
}