14
14
use PHPUnit \Framework \TestCase ;
15
15
use Symfony \Component \Cache \Adapter \ArrayAdapter ;
16
16
use Symfony \Component \Clock \ClockInterface ;
17
+ use Symfony \Component \Clock \MockClock ;
17
18
use Symfony \Component \Scheduler \Generator \Checkpoint ;
18
19
use Symfony \Component \Scheduler \Generator \MessageContext ;
19
20
use Symfony \Component \Scheduler \Generator \MessageGenerator ;
@@ -131,10 +132,7 @@ public function testYieldedContext()
131
132
132
133
public function testCheckpointSavedInBrokenLoop ()
133
134
{
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 ' ));
138
136
139
137
$ message = $ this ->createMessage ((object ) ['id ' => 'message ' ], '22:13:00 ' , '22:14:00 ' , '22:16:00 ' );
140
138
$ schedule = (new Schedule ())->add ($ message );
@@ -148,7 +146,7 @@ public function testCheckpointSavedInBrokenLoop()
148
146
// Warmup. The first run is always returns nothing.
149
147
$ this ->assertSame ([], iterator_to_array ($ scheduler ->getMessages (), false ));
150
148
151
- $ now = self :: makeDateTime ( ' 22:13:10 ' );
149
+ $ clock -> sleep ( 60 + 10 ); // 22:13:10
152
150
153
151
foreach ($ scheduler ->getMessages () as $ message ) {
154
152
// Message is handled but loop is broken just after
0 commit comments