Move createAutomationRun method to integration tester

[MAILPOET-4966]
This commit is contained in:
David Remer
2023-02-03 08:10:35 +02:00
committed by Aschepikov
parent 7379b83a92
commit cd9bf9107f
2 changed files with 25 additions and 22 deletions

View File

@ -44,7 +44,7 @@ class StepHandlerTest extends \MailPoetTest {
$automation = $this->createAutomation();
$this->assertInstanceOf(Automation::class, $automation);
$steps = $automation->getSteps();
$automationRun = $this->createAutomationRun($automation);
$automationRun = $this->tester->createAutomationRun($automation);
$this->assertInstanceOf(AutomationRun::class, $automationRun);
$currentStep = current($steps);
@ -79,7 +79,7 @@ class StepHandlerTest extends \MailPoetTest {
foreach ($invalidStati as $status) {
$automation->setStatus($status);
$this->automationStorage->updateAutomation($automation);
$automationRun = $this->createAutomationRun($automation);
$automationRun = $this->tester->createAutomationRun($automation);
$this->assertInstanceOf(AutomationRun::class, $automationRun);
$error = null;
try {
@ -99,9 +99,9 @@ class StepHandlerTest extends \MailPoetTest {
public function testAnDeactivatingAutomationBecomesDraftAfterLastRunIsExecuted() {
$automation = $this->createAutomation();
$this->assertInstanceOf(Automation::class, $automation);
$automationRun1 = $this->createAutomationRun($automation);
$automationRun1 = $this->tester->createAutomationRun($automation);
$this->assertInstanceOf(AutomationRun::class, $automationRun1);
$automationRun2 = $this->createAutomationRun($automation);
$automationRun2 = $this->tester->createAutomationRun($automation);
$this->assertInstanceOf(AutomationRun::class, $automationRun2);
$automation->setStatus(Automation::STATUS_DEACTIVATING);
$this->automationStorage->updateAutomation($automation);
@ -139,24 +139,6 @@ class StepHandlerTest extends \MailPoetTest {
);
}
private function createAutomationRun(Automation $automation, $subjects = []): ?AutomationRun {
$trigger = array_filter($automation->getSteps(), function(Step $step): bool { return $step->getType() === Step::TYPE_TRIGGER;
});
$triggerKeys = array_map(function(Step $step): string { return $step->getKey();
}, $trigger);
$triggerKey = count($triggerKeys) > 0 ? current($triggerKeys) : '';
$automationRun = new AutomationRun(
$automation->getId(),
$automation->getVersionId(),
$triggerKey,
$subjects
);
return $this->automationRunStorage->getAutomationRun($this->automationRunStorage->createAutomationRun($automationRun));
}
public function _after() {
$this->automationStorage->truncate();
$this->automationRunStorage->truncate();