@@ -43,14 +43,16 @@ public static function setUpBeforeClass(): void
4343
4444 for ($ i = 0 ; $ i < self ::NUMBER_OF_WORKERS ; $ i ++) {
4545 self ::$ workers [$ i ] = new Process (['php ' , __DIR__ . '/../vendor/bin/testbench ' , 'queue:work ' ]);
46- if (! self ::shouldStreamWorkerOutput ()) {
46+ if (! self ::shouldCaptureWorkerOutput ()) {
4747 self ::$ workers [$ i ]->disableOutput ();
4848 self ::$ workers [$ i ]->start ();
4949 continue ;
5050 }
5151
52+ file_put_contents (self ::workerLogPath ($ i ), '' );
53+
5254 self ::$ workers [$ i ]->start (static function (string $ type , string $ output ) use ($ i ): void {
53- fwrite ( STDERR , ' [worker- ' . $ i . ' ][ ' . $ type . ' ] ' . $ output );
55+ file_put_contents ( self :: workerLogPath ( $ i ), $ output , FILE_APPEND | LOCK_EX );
5456 });
5557 }
5658 }
@@ -102,10 +104,19 @@ protected function getPackageProviders($app)
102104 return [\Workflow \Providers \WorkflowServiceProvider::class];
103105 }
104106
105- private static function shouldStreamWorkerOutput (): bool
107+ private static function shouldCaptureWorkerOutput (): bool
106108 {
107- $ value = getenv ('WORKFLOW_TEST_STREAM_WORKER_OUTPUT ' ) ?: ($ _ENV ['WORKFLOW_TEST_STREAM_WORKER_OUTPUT ' ] ?? null );
109+ $ value = getenv (
110+ 'WORKFLOW_TEST_CAPTURE_WORKER_OUTPUT '
111+ ) ?: ($ _ENV ['WORKFLOW_TEST_CAPTURE_WORKER_OUTPUT ' ] ?? null );
108112
109113 return in_array ($ value , ['1 ' , 'true ' , 'yes ' , 'on ' ], true );
110114 }
115+
116+ private static function workerLogPath (int $ worker ): string
117+ {
118+ return dirname (
119+ __DIR__
120+ ) . '/vendor/orchestra/testbench-core/laravel/storage/logs/workflow-test-worker- ' . $ worker . '.log ' ;
121+ }
111122}
0 commit comments