Skip to content

Commit

Permalink
Added sleep test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamielsharief committed Feb 24, 2021
1 parent 957062a commit 7fd54da
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/TestCase/Console/Command/QueueWorkerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,34 @@ public function testMaintenanceMode()
$this->assertOutputContains('<pass> OK </pass>');
}


public function testMaxSeconds()
{
(new PassOrFailJob())->dispatch(true);

$started = time();

$this->exec('queue:worker -d --seconds=2 --sleep=0 --connection=test');

$took = time() - $started ;

$this->assertGreaterThanOrEqual(2, $took);
}

/*
* @depends testMaxSeconds
*/
public function testSleep()
{
$started = time();

$this->exec('queue:worker -d --seconds=2 --sleep=0');
$this->exec('queue:worker -d --seconds=1 --sleep=2');

$took = time() - $started ;

$this->assertGreaterThan(2, $took);
$this->assertGreaterThanOrEqual(2, $took);
}


public function deleteFile(string $file) : void
{
if (file_exists($file)) {
Expand Down

0 comments on commit 7fd54da

Please sign in to comment.