File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,9 @@ public function subscribeToProcessOutput(Process $process): void
7575 $ process ->stdout ->on ('data ' , static function ($ data ) {
7676 echo $ data ;
7777 });
78+ $ process ->stderr ->on ('data ' , static function ($ data ) {
79+ echo $ data ;
80+ });
7881 }
7982
8083 public function showSpinner (LoopInterface $ loop ): void
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ public static function createHelloWorldPHPFile(): string
2424 return $ name ;
2525 }
2626
27+ public static function createStdErrorPHPFile (): string
28+ {
29+ $ name = self ::FIXTURES_DIR . 'test.php ' ;
30+ self ::createFile ($ name , '<?php fwrite(STDERR, "Some error"); ' );
31+
32+ return $ name ;
33+ }
34+
2735 public static function createHelloWorldPHPFileWithSignalsHandling (): string
2836 {
2937 $ name = self ::FIXTURES_DIR . 'test.php ' ;
Original file line number Diff line number Diff line change @@ -20,4 +20,16 @@ public function it_runs_a_php_script(): void
2020 $ this ->assertStringContainsString ("starting `php $ scriptToRun` " , $ output );
2121 $ this ->assertStringContainsString ('Hello, world ' , $ output );
2222 }
23+
24+ /** @test */
25+ public function it_outputs_the_script_stderr (): void
26+ {
27+ $ scriptToRun = Filesystem::createStdErrorPHPFile ();
28+ $ watcher = (new WatcherRunner )->run ($ scriptToRun );
29+
30+ $ this ->wait ();
31+ $ output = $ watcher ->getOutput ();
32+
33+ $ this ->assertStringContainsString ('Some error ' , $ output );
34+ }
2335}
You can’t perform that action at this time.
0 commit comments