$this->createStep('root', Step::TYPE_ROOT, ['t']), 't' => $this->createStep('t', Step::TYPE_TRIGGER), ]; $automation = $this->make(Automation::class, ['getSteps' => $steps, 'getStep' => function($id) use ($steps) { return $steps[$id] ?? null; }]); $automation->setStatus(Automation::STATUS_ACTIVE); (new AutomationWalker())->walk($automation, [new AtLeastOneTriggerRule()]); //no exception thrown. } public function testItFailsWhenNoTriggerExists(): void { $steps = [ 'root' => $this->createStep('root', Step::TYPE_ROOT), ]; $automation = $this->make(Automation::class, ['getSteps' => $steps, 'getStep' => function($id) use ($steps) { return $steps[$id] ?? null; }]); $automation->setStatus(Automation::STATUS_ACTIVE); $this->expectException(UnexpectedValueException::class); $this->expectExceptionMessage('Invalid automation structure: There must be at least one trigger in the automation.'); (new AutomationWalker())->walk($automation, [new AtLeastOneTriggerRule()]); } }