99use Cake \Core \Configure ;
1010use Cake \ORM \TableRegistry ;
1111use Cake \TestSuite \TestCase ;
12+ use Cake \I18n \Time ;
1213
1314/**
1415 * Queue\Model\Table\QueuedTasksTable Test Case
@@ -215,9 +216,9 @@ public function testNotBefore() {
215216 $ this ->assertTrue ((bool )$ this ->QueuedTasks ->createJob ('task1 ' , [], '+ 1 Day ' ));
216217 $ this ->assertTrue ((bool )$ this ->QueuedTasks ->createJob ('task1 ' , [], '2009-07-01 12:00:00 ' ));
217218 $ data = $ this ->QueuedTasks ->find ('all ' )->toArray ();
218- $ this ->assertWithinRange (strtotime ( '+ 1 Min ' ), $ data [0 ]['notbefore ' ]->toUnixString (), 60 );
219- $ this ->assertWithinRange (strtotime ( '+ 1 Day ' ), $ data [1 ]['notbefore ' ]->toUnixString (), 60 );
220- $ this ->assertWithinRange (strtotime ( '2009-07-01 12:00:00 ' ), $ data [2 ]['notbefore ' ]->toUnixString (), 60 );
219+ $ this ->assertWithinRange (( new Time ( '+ 1 Min ' ))-> toUnixString ( ), $ data [0 ]['notbefore ' ]->toUnixString (), 60 );
220+ $ this ->assertWithinRange (( new Time ( '+ 1 Day ' ))-> toUnixString ( ), $ data [1 ]['notbefore ' ]->toUnixString (), 60 );
221+ $ this ->assertWithinRange (( new Time ( '2009-07-01 12:00:00 ' ))-> toUnixString ( ), $ data [2 ]['notbefore ' ]->toUnixString (), 60 );
221222 }
222223
223224 /**
@@ -291,7 +292,7 @@ public function testRateLimit() {
291292 'name ' => 'task1 ' ,
292293 'timeout ' => 101 ,
293294 'retries ' => 2 ,
294- 'rate ' => 1 ,
295+ 'rate ' => 2 ,
295296 ],
296297 'dummytask ' => [
297298 'name ' => 'dummytask ' ,
@@ -323,15 +324,15 @@ public function testRateLimit() {
323324 $ this ->assertEquals ('dummytask ' , $ tmp ['jobtype ' ]);
324325 $ this ->assertNull (unserialize ($ tmp ['data ' ]));
325326
326- usleep (500000 );
327+ usleep (100000 );
327328 //and again.
328329 $ this ->QueuedTasks ->clearKey ();
329330 $ tmp = $ this ->QueuedTasks ->requestJob ($ capabilities );
330331 $ this ->assertEquals ('dummytask ' , $ tmp ['jobtype ' ]);
331332 $ this ->assertNull (unserialize ($ tmp ['data ' ]));
332333
333334 //Then some time passes
334- sleep (1 );
335+ sleep (2 );
335336
336337 //Now we should get task1-2
337338 $ this ->QueuedTasks ->clearKey ();
@@ -346,7 +347,7 @@ public function testRateLimit() {
346347 $ this ->assertNull (unserialize ($ tmp ['data ' ]));
347348
348349 //Then some more time passes
349- sleep (1 );
350+ sleep (2 );
350351
351352 //Now we should get task1-3
352353 $ this ->QueuedTasks ->clearKey ();
0 commit comments