Skip to content

Commit d17ed65

Browse files
committed
Adjust test case details
1 parent b51c467 commit d17ed65

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/AsyncTaskStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getEncodedTaskID(): string
6363
}
6464

6565
/**
66-
* Returns whether the AsyncTask is still running.
66+
* Checks and returns whether the AsyncTask is still running. This may take a bit of time.
6767
*
6868
* Note: when this method detects that the task has stopped running, it will not recheck whether the task has restarted.
6969
* Use a fresh status object to track the (restarted) task.

tests/AsyncTaskTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,9 @@ public function testAsyncTaskNormalStatus()
248248
$liveStatus = $task->start();
249249

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

0 commit comments

Comments
 (0)