@@ -73,11 +73,33 @@ public function testSendWithDelay()
7373 $ stmt = $ stmt ->execute ();
7474 }
7575
76- $ available_at = new \DateTime ($ stmt instanceof Result || $ stmt instanceof DriverResult ? $ stmt ->fetchOne () : $ stmt ->fetchColumn ());
76+ $ availableAt = new \DateTime ($ stmt instanceof Result || $ stmt instanceof DriverResult ? $ stmt ->fetchOne () : $ stmt ->fetchColumn ());
7777
7878 $ now = new \DateTime ();
7979 $ now ->modify ('+60 seconds ' );
80- $ this ->assertGreaterThan ($ now , $ available_at );
80+ $ this ->assertGreaterThan ($ now , $ availableAt );
81+ }
82+
83+ public function testSendWithNegativeDelay ()
84+ {
85+ $ this ->connection ->send ('{"message": "Hi I am not actually delayed"} ' , ['type ' => DummyMessage::class], -600000 );
86+
87+ $ stmt = $ this ->driverConnection ->createQueryBuilder ()
88+ ->select ('m.available_at ' )
89+ ->from ('messenger_messages ' , 'm ' )
90+ ->where ('m.body = :body ' )
91+ ->setParameter ('body ' , '{"message": "Hi I am not actually delayed"} ' );
92+ if (method_exists ($ stmt , 'executeQuery ' )) {
93+ $ stmt = $ stmt ->executeQuery ();
94+ } else {
95+ $ stmt = $ stmt ->execute ();
96+ }
97+
98+ $ availableAt = new \DateTime ($ stmt instanceof Result || $ stmt instanceof DriverResult ? $ stmt ->fetchOne () : $ stmt ->fetchColumn ());
99+
100+ $ now = new \DateTime ();
101+ $ now ->modify ('-60 seconds ' );
102+ $ this ->assertLessThan ($ now , $ availableAt );
81103 }
82104
83105 public function testItRetrieveTheFirstAvailableMessage ()
0 commit comments