Skip to content

Commit d15c34b

Browse files
committed
minor symfony#52354 [Scheduler] fix test (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [Scheduler] fix test | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- 2f03942 fix test
2 parents fc41bf5 + 2f03942 commit d15c34b

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ public function testGetMessagesFromScheduleProviderWithRestart()
100100
];
101101
$schedule = [[$first, '22:13:00', '22:14:00']];
102102

103-
// for referencing
104-
$now = self::makeDateTime($startTime);
105-
106-
$clock = $this->createMock(ClockInterface::class);
107-
$clock->method('now')->willReturnReference($now);
103+
$clock = new MockClock(self::makeDateTime($startTime));
108104

109105
foreach ($schedule as $i => $s) {
110106
if (\is_array($s)) {
@@ -142,15 +138,15 @@ public function add(RecurringMessage $message): self
142138
$toAdd = (object) ['id' => 'added-after-start'];
143139

144140
foreach ($runs as $time => $expected) {
145-
$now = self::makeDateTime($time);
141+
$clock->modify($time);
146142
$this->assertSame($expected, iterator_to_array($scheduler->getMessages(), false));
147143
}
148144

149145
$scheduleProvider->add($this->createMessage($toAdd, '22:13:10', '22:13:11'));
150146

151147
$this->assertSame([], iterator_to_array($scheduler->getMessages(), false));
152148

153-
$now = self::makeDateTime('22:13:10');
149+
$clock->sleep(9);
154150
$this->assertSame([$toAdd], iterator_to_array($scheduler->getMessages(), false));
155151
}
156152

0 commit comments

Comments
 (0)