Skip to content

Commit

Permalink
Adjust test case details
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorial1024 committed Jan 22, 2025
1 parent b51c467 commit d17ed65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/AsyncTaskStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function getEncodedTaskID(): string
}

/**
* Returns whether the AsyncTask is still running.
* Checks and returns whether the AsyncTask is still running. This may take a bit of time.
*
* Note: when this method detects that the task has stopped running, it will not recheck whether the task has restarted.
* Use a fresh status object to track the (restarted) task.
Expand Down
13 changes: 4 additions & 9 deletions tests/AsyncTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,9 @@ public function testAsyncTaskNormalStatus()
$liveStatus = $task->start();

// the task is to sleep for 2 seconds, and then exit.
for ($i = 0; $i < 2; $i++) {
// check the statuses; most likely still be running
$this->assertFalse($preStatus->isRunning(), "Incorrect pre-run task status at loop $i");
$this->assertTrue($liveStatus->isRunning(), "Incorrect live-run task status at loop $i");
$this->sleep(0.9);
}
// should have finished
$this->assertFalse($preStatus->isRunning(), "Incorrect pre-run task status at loop end");
$this->assertFalse($liveStatus->isRunning(), "Incorrect live-run task status at loop end");
// note: since checking the task statuses take some time, we cannot confirm the actual elapsed time of our tests,
// and so "task ended" case is not testable
$this->assertFalse($preStatus->isRunning(), "Stopped tasks should always report \"task stopped\".");
$this->assertTrue($liveStatus->isRunning(), "Recently-started task does not report \"task running\".");
}
}

0 comments on commit d17ed65

Please sign in to comment.