File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Vectorial1024 \LaravelProcessAsync \Tests ;
44
5+ use InvalidArgumentException ;
56use LogicException ;
67use RuntimeException ;
78use Vectorial1024 \LaravelProcessAsync \AsyncTask ;
9+ use Vectorial1024 \LaravelProcessAsync \AsyncTaskStatus ;
810use Vectorial1024 \LaravelProcessAsync \Tests \Tasks \DummyAsyncTask ;
11+ use Vectorial1024 \LaravelProcessAsync \Tests \Tasks \SleepingAsyncTask ;
912use Vectorial1024 \LaravelProcessAsync \Tests \Tasks \TestTimeoutENoticeTask ;
1013use Vectorial1024 \LaravelProcessAsync \Tests \Tasks \TestTimeoutErrorTask ;
1114use Vectorial1024 \LaravelProcessAsync \Tests \Tasks \TestTimeoutNoOpTask ;
@@ -204,4 +207,25 @@ public function testAsyncTimeoutIgnoreENotice()
204207 $ this ->assertFileDoesNotExist ($ textFilePath , "The async task timeout handler was inappropriately triggered (E_NOTICE should not trigger timeouts). " );
205208 $ this ->assertNoNohupFile ();
206209 }
210+
211+ public function testAsyncTaskID ()
212+ {
213+ // test that we can correctly handle good and bad task IDs
214+
215+ // no ID is ok
216+ $ task = new AsyncTask (new SleepingAsyncTask ());
217+ unset($ task );
218+
219+ // has ID is also ok
220+ $ task = new AsyncTask (new SleepingAsyncTask (), taskID: "yeah " );
221+ unset($ task );
222+
223+ // but blank ID is not allowed
224+ $ this ->expectException (InvalidArgumentException::class);
225+ $ task = new AsyncTask (new SleepingAsyncTask (), taskID: "" );
226+ unset($ task );
227+ $ this ->expectException (InvalidArgumentException::class);
228+ $ taskStatus = new AsyncTaskStatus ("" );
229+ unset($ taskStatus );
230+ }
207231}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Vectorial1024 \LaravelProcessAsync \Tests \Tasks ;
4+
5+ use Vectorial1024 \LaravelProcessAsync \AsyncTaskInterface ;
6+
7+ class SleepingAsyncTask implements AsyncTaskInterface
8+ {
9+ // just sleeps for 5 seconds, and finish
10+
11+ public function __construct ()
12+ {
13+ }
14+
15+ public function execute (): void
16+ {
17+ sleep (5 );
18+ }
19+
20+ public function handleTimeout (): void
21+ {
22+ // nothing for now
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments