@@ -43,13 +43,17 @@ public function setUp(): void
4343 'ssh_port ' => (int ) getenv ('ROS_SSH_PORT ' ),
4444 ];
4545
46- $ this ->client = new class ($ this ->config ) extends Client {
46+ $ this ->client =
47+
48+ new class ($ this ->config ) extends Client {
49+
4750 // Convert protected method to public
4851 public function pregResponse (string $ value , ?array &$ matches ): void
4952 {
5053 parent ::pregResponse ($ value , $ matches );
5154 }
52- };
55+
56+ };
5357
5458 $ this ->portModern = (int ) getenv ('ROS_PORT_MODERN ' );
5559 $ this ->portLegacy = (int ) getenv ('ROS_PORT_LEGACY ' );
@@ -353,4 +357,23 @@ public function test_export_asQuery(): void
353357 $ result = $ this ->client ->query ('/export ' );
354358 self ::assertNotEmpty ($ result );
355359 }
360+
361+ public function test_parseResponse_emptyArrayHandling (): void
362+ {
363+ // Simulate responses that could come from nested script execution
364+ $ emptyResponse = [];
365+ $ result = $ this ->client ->parseResponse ($ emptyResponse );
366+ self ::assertIsArray ($ result );
367+ self ::assertEmpty ($ result );
368+
369+ // Response with only control words (no data)
370+ $ doneOnlyResponse = ['!done ' ];
371+ $ result = $ this ->client ->parseResponse ($ doneOnlyResponse );
372+ self ::assertIsArray ($ result );
373+
374+ // Response with trap (error case)
375+ $ trapResponse = ['!trap ' , '=message=no such command ' ];
376+ $ result = $ this ->client ->parseResponse ($ trapResponse );
377+ self ::assertIsArray ($ result );
378+ }
356379}
0 commit comments