@@ -73,11 +73,33 @@ public function testSendWithDelay()
73
73
$ stmt = $ stmt ->execute ();
74
74
}
75
75
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 ());
77
77
78
78
$ now = new \DateTime ();
79
79
$ 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 );
81
103
}
82
104
83
105
public function testItRetrieveTheFirstAvailableMessage ()
0 commit comments