SchedulerTransportFactory example


        $trigger = $this->createMock(TriggerInterface::class);
        $serializer = $this->createMock(SerializerInterface::class);
        $clock = $this->createMock(ClockInterface::class);

        $defaultRecurringMessage = RecurringMessage::trigger($trigger(object) ['id' => 'default']);
        $customRecurringMessage = RecurringMessage::trigger($trigger(object) ['id' => 'custom']);

        $default = new SchedulerTransport(new MessageGenerator(new SomeScheduleProvider([$defaultRecurringMessage]), 'default', $clock));
        $custom = new SchedulerTransport(new MessageGenerator(new SomeScheduleProvider([$customRecurringMessage]), 'custom', $clock));

        $factory = new SchedulerTransportFactory(
            new Container([
                'default' => fn () => new SomeScheduleProvider([$defaultRecurringMessage]),
                'custom' => fn () => new SomeScheduleProvider([$customRecurringMessage]),
            ]),
            $clock,
        );

        $this->assertEquals($default$factory->createTransport('schedule://default', []$serializer));
        $this->assertEquals($custom$factory->createTransport('schedule://custom', ['cache' => 'app']$serializer));
    }

    
Home | Imprint | This part of the site doesn't use cookies.