getCallingTimezoneMode()); self::assertSame(3, $script->getRetryMaxAttempts()); self::assertSame(30, $script->getRetryDelayMinutes()); self::assertSame(CallScriptRetryBackoff::None, $script->getRetryBackoff()); self::assertSame([], $script->getCallingDays()); self::assertCount(0, $script->getOutcomes()); } public function testCallingDaysAreFilteredAndDeduplicated(): void { $script = new CallScript(); $script->setCallingDays(['mon', 'mon', 'xxx', 'fri']); self::assertSame(['mon', 'fri'], $script->getCallingDays()); } public function testNormalizePositionsRenumbersTheOutcomes(): void { $script = new CallScript(); $first = (new CallScriptOutcome())->setLabel('First')->setPosition(7); $second = (new CallScriptOutcome())->setLabel('Second')->setPosition(2); $script->addOutcome($first); $script->addOutcome($second); $script->normalizePositions(); self::assertSame(0, $second->getPosition()); self::assertSame(1, $first->getPosition()); self::assertSame(['Second', 'First'], array_map(fn (CallScriptOutcome $o): ?string => $o->getLabel(), $script->getOutcomes()->toArray())); } public function testOutcomeOptionsAreSanitized(): void { $outcome = new CallScriptOutcome(); $outcome->setOptions([ ['value' => 'yes', 'label' => 'Yes'], ['value' => '', 'label' => ''], ['value' => 'maybe', 'label' => ''], ]); self::assertSame([ ['value' => 'yes', 'label' => 'Yes'], ['value' => 'maybe', 'label' => 'maybe'], ], $outcome->getOptions()); } public function testNullEnumsAndNumbersKeepTheCurrentValues(): void { $script = new CallScript(); $script->setCallingTimezoneMode(CallScriptTimezoneMode::Fixed); $script->setRetryBackoff(CallScriptRetryBackoff::Exponential); $script->setRetryMaxAttempts(5); $script->setCallingTimezoneMode(null); $script->setRetryBackoff(null); $script->setRetryMaxAttempts(null); self::assertSame(CallScriptTimezoneMode::Fixed, $script->getCallingTimezoneMode()); self::assertSame(CallScriptRetryBackoff::Exponential, $script->getRetryBackoff()); self::assertSame(5, $script->getRetryMaxAttempts()); } public function testDateRangeInterfaceMapsTheValidityWindow(): void { $script = new CallScript(); $start = new \DateTime('2026-01-10 09:00:00'); $end = new \DateTime('2026-01-12 18:00:00'); $script->setPublishUp($start); $script->setPublishDown($end); self::assertSame($start, $script->getStartDate()); self::assertSame($end, $script->getEndDate()); } public function testOutcomeInputTypesDeclareWhetherTheyHaveOptions(): void { self::assertFalse(CallScriptOutcomeInputType::FreeText->hasOptions()); self::assertTrue(CallScriptOutcomeInputType::Checkbox->hasOptions()); self::assertTrue(CallScriptOutcomeInputType::Radio->hasOptions()); self::assertTrue(CallScriptOutcomeInputType::Dropdown->hasOptions()); } }