CallbackTrigger example

$tester = new CommandTester($command);

        $tester->execute([]['decorated' => false]);

        $filler = str_repeat(' ', 92);
        $this->assertSame("\nScheduler\n=========\n\n [ERROR] No schedules found.{$filler}\n\n", $tester->getDisplay(true));
    }

    public function testExecuteWithScheduleWithoutTriggerDoesNotDisplayMessage()
    {
        $schedule = new Schedule();
        $schedule->add(RecurringMessage::trigger(new CallbackTrigger(fn () => null, 'test')new \stdClass()));

        $schedules = $this->createMock(ServiceProviderInterface::class);
        $schedules
            ->expects($this->once())
            ->method('getProvidedServices')
            ->willReturn(['schedule_name' => $schedule])
        ;
        $schedules
            ->expects($this->once())
            ->method('get')
            ->willReturn($schedule)
        ;


namespace Symfony\Component\Scheduler\Tests\Trigger;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Scheduler\Trigger\CallbackTrigger;

class CallbackTriggerTest extends TestCase
{
    public function testToString()
    {
        $trigger = new CallbackTrigger(fn () => null);
        $this->assertMatchesRegularExpression('/^[\da-f]{32}$/', (string) $trigger);

        $trigger = new CallbackTrigger(fn () => null, '');
        $this->assertSame('', (string) $trigger);

        $trigger = new CallbackTrigger(fn () => null, 'foo');
        $this->assertSame('foo', (string) $trigger);
    }
}
Home | Imprint | This part of the site doesn't use cookies.