Skip to content

Commit 008a98a

Browse files
committed
Replace Mock by MockClock
1 parent 6e1c193 commit 008a98a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Cache\Adapter\ArrayAdapter;
1616
use Symfony\Component\Clock\ClockInterface;
17+
use Symfony\Component\Clock\MockClock;
1718
use Symfony\Component\Scheduler\Generator\Checkpoint;
1819
use Symfony\Component\Scheduler\Generator\MessageContext;
1920
use Symfony\Component\Scheduler\Generator\MessageGenerator;
@@ -131,10 +132,7 @@ public function testYieldedContext()
131132

132133
public function testCheckpointSavedInBrokenLoop()
133134
{
134-
$now = self::makeDateTime('22:12:00');
135-
136-
$clock = $this->createMock(ClockInterface::class);
137-
$clock->method('now')->willReturnReference($now);
135+
$clock = new MockClock(self::makeDateTime('22:12:00'));
138136

139137
$message = $this->createMessage((object) ['id' => 'message'], '22:13:00', '22:14:00', '22:16:00');
140138
$schedule = (new Schedule())->add($message);
@@ -148,7 +146,7 @@ public function testCheckpointSavedInBrokenLoop()
148146
// Warmup. The first run is always returns nothing.
149147
$this->assertSame([], iterator_to_array($scheduler->getMessages(), false));
150148

151-
$now = self::makeDateTime('22:13:10');
149+
$clock->sleep(60 + 10); // 22:13:10
152150

153151
foreach ($scheduler->getMessages() as $message) {
154152
// Message is handled but loop is broken just after

0 commit comments

Comments
 (0)