Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite6148f1

Browse files
committed
Add tests for checkpoint saved in broken loop
1 parentd460ba4 commite6148f1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎src/Symfony/Component/Scheduler/Tests/Generator/MessageGeneratorTest.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
usePHPUnit\Framework\TestCase;
1515
useSymfony\Component\Cache\Adapter\ArrayAdapter;
1616
useSymfony\Component\Clock\ClockInterface;
17+
useSymfony\Component\Scheduler\Generator\Checkpoint;
1718
useSymfony\Component\Scheduler\Generator\MessageContext;
1819
useSymfony\Component\Scheduler\Generator\MessageGenerator;
1920
useSymfony\Component\Scheduler\RecurringMessage;
@@ -128,6 +129,35 @@ public function testYieldedContext()
128129
$this->assertEquals(self::makeDateTime('22:16:00'),$context->nextTriggerAt);
129130
}
130131

132+
publicfunctiontestCheckpointSavedInBrokenLoop():void
133+
{
134+
$now =self::makeDateTime('22:12:00');
135+
136+
$clock =$this->createMock(ClockInterface::class);
137+
$clock->method('now')->willReturnReference($now);
138+
139+
$message =$this->createMessage((object) ['id' =>'message'],'22:13:00','22:14:00','22:16:00');
140+
$schedule = (newSchedule())->add($message);
141+
142+
$cache =newArrayAdapter();
143+
$schedule->stateful($cache);
144+
$checkpoint =newCheckpoint('dummy', cache:$cache);
145+
146+
$scheduler =newMessageGenerator($schedule,'dummy', clock:$clock, checkpoint:$checkpoint);
147+
148+
// Warmup. The first run is always returns nothing.
149+
$this->assertSame([],iterator_to_array($scheduler->getMessages(),false));
150+
151+
$now =self::makeDateTime('22:13:10');
152+
153+
foreach ($scheduler->getMessages()as$message) {
154+
// Message is handled but loop is broken just after
155+
break;
156+
}
157+
158+
$this->assertEquals(self::makeDateTime('22:13:00'),$checkpoint->time());
159+
}
160+
131161
publicstaticfunctionmessagesProvider():\Generator
132162
{
133163
$first = (object) ['id' =>'first'];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp