File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ public function start(): void
7070 {
7171 // assume unix for now
7272 $ serializedTask = $ this ->toBase64Serial ();
73- $ this ->theTask = Process::quietly ()->start ("php artisan async:run $ serializedTask " );
73+ $ this ->runnerProcess = Process::quietly ()->start ("php artisan async:run $ serializedTask " );
7474 }
7575
7676 /**
Original file line number Diff line number Diff line change 66
77class AsyncTaskTest extends BaseTestCase
88{
9+ // directly running the runner
10+
911 public function testCanRunClosure ()
1012 {
1113 // tests that our AsyncTask can run closures correctly.
@@ -39,4 +41,30 @@ public function testCanRunInterface()
3941
4042 unlink ($ testFileName );
4143 }
44+
45+ // ---------
46+
47+ // integration test with the cli artisan via a mocked artisan file, which tests various features of this library
48+
49+ public function testAsyncBasic ()
50+ {
51+ // tests that we can dispatch async tasks to the cli artisan
52+ $ testFileName = $ this ->getStoragePath ("testAsyncBasic.txt " );
53+ $ message = "Hello world! " ;
54+ $ task = new AsyncTask (function () use ($ testFileName , $ message ) {
55+ $ fp = fopen ($ testFileName , "w " );
56+ fwrite ($ fp , $ message );
57+ fflush ($ fp );
58+ fclose ($ fp );
59+ });
60+ $ task ->start ();
61+
62+ // sleep a bit to wait for the async
63+ sleep (1 );
64+
65+ $ this ->assertFileExists ($ testFileName );
66+ $ this ->assertStringEqualsFile ($ testFileName , $ message );
67+
68+ unlink ($ testFileName );
69+ }
4270}
You can’t perform that action at this time.
0 commit comments