@@ -89,7 +89,7 @@ public function test_delayed_message_observes_clock_changes_natively_by_moving_t
8989 );
9090 }
9191
92- public function test_delayed_message_is_released_when_moving_time_forward_using_with_current_time (): void
92+ public function test_delayed_message_is_released_when_moving_time_forward_using_change_time (): void
9393 {
9494 $ ecotoneTestSupport = EcotoneLite::bootstrapFlowTesting (
9595 [OrderService::class, NotificationService::class, CustomNotifier::class],
@@ -104,13 +104,34 @@ public function test_delayed_message_is_released_when_moving_time_forward_using_
104104 $ ecotoneTestSupport ->run ('notifications ' );
105105 $ this ->assertCount (0 , $ notifier ->getNotificationsOf ('placedOrder ' ));
106106
107- $ ecotoneTestSupport ->withCurrentTime (new \DateTimeImmutable ('2025-08-11 16:01:01 ' ));
107+ $ ecotoneTestSupport ->changeTime (new \DateTimeImmutable ('2025-08-11 16:01:01 ' ));
108108 $ ecotoneTestSupport ->run ('notifications ' );
109109
110110 $ this ->assertCount (1 , $ notifier ->getNotificationsOf ('placedOrder ' ));
111111 }
112112
113- public function test_first_with_current_time_call_allows_any_time (): void
113+ public function test_delayed_message_is_released_when_advancing_time_using_duration (): void
114+ {
115+ $ ecotoneTestSupport = EcotoneLite::bootstrapFlowTesting (
116+ [OrderService::class, NotificationService::class, CustomNotifier::class],
117+ [ClockInterface::class => new StaticPsrClock ('2025-08-11 16:00:00 ' ), new OrderService (), new NotificationService (), $ notifier = new CustomNotifier ()],
118+ enableAsynchronousProcessing: [
119+ SimpleMessageChannelBuilder::createQueueChannel ('notifications ' , true ),
120+ ]
121+ );
122+
123+ $ ecotoneTestSupport ->sendCommandWithRoutingKey ('order.register ' , new PlaceOrder ('123 ' ));
124+
125+ $ ecotoneTestSupport ->run ('notifications ' );
126+ $ this ->assertCount (0 , $ notifier ->getNotificationsOf ('placedOrder ' ));
127+
128+ $ ecotoneTestSupport ->changeTime (Duration::minutes (2 ));
129+ $ ecotoneTestSupport ->run ('notifications ' );
130+
131+ $ this ->assertCount (1 , $ notifier ->getNotificationsOf ('placedOrder ' ));
132+ }
133+
134+ public function test_first_change_time_call_allows_any_time (): void
114135 {
115136 $ ecotoneTestSupport = EcotoneLite::bootstrapFlowTesting (
116137 [OrderService::class, NotificationService::class, CustomNotifier::class],
@@ -120,12 +141,12 @@ public function test_first_with_current_time_call_allows_any_time(): void
120141 ]
121142 );
122143
123- $ ecotoneTestSupport ->withCurrentTime (new \DateTimeImmutable ('2020-01-01 12:00:00 ' ));
144+ $ ecotoneTestSupport ->changeTime (new \DateTimeImmutable ('2020-01-01 12:00:00 ' ));
124145
125146 $ this ->assertEquals ('2020-01-01 12:00:00 ' , $ ecotoneTestSupport ->getServiceFromContainer (ClockInterface::class)->now ()->format ('Y-m-d H:i:s ' ));
126147 }
127148
128- public function test_with_current_time_throws_exception_when_moving_backwards_after_first_setup (): void
149+ public function test_change_time_throws_exception_when_moving_backwards_after_first_setup (): void
129150 {
130151 $ ecotoneTestSupport = EcotoneLite::bootstrapFlowTesting (
131152 [OrderService::class, NotificationService::class, CustomNotifier::class],
@@ -135,11 +156,11 @@ public function test_with_current_time_throws_exception_when_moving_backwards_af
135156 ]
136157 );
137158
138- $ ecotoneTestSupport ->withCurrentTime (new \DateTimeImmutable ('2025-08-11 17:00:00 ' ));
159+ $ ecotoneTestSupport ->changeTime (new \DateTimeImmutable ('2025-08-11 17:00:00 ' ));
139160
140161 $ this ->expectException (\InvalidArgumentException::class);
141162 $ this ->expectExceptionMessage ('Cannot move time backwards ' );
142163
143- $ ecotoneTestSupport ->withCurrentTime (new \DateTimeImmutable ('2025-08-11 16:30:00 ' ));
164+ $ ecotoneTestSupport ->changeTime (new \DateTimeImmutable ('2025-08-11 16:30:00 ' ));
144165 }
145166}
0 commit comments