@@ -289,4 +289,79 @@ public function test_null_values_are_handled() {
289289 ];
290290 $ this ->assertSame ( $ expected , $ out , 'Null values should be safely converted to empty strings in table output. ' );
291291 }
292+
293+ public function test_resetRows () {
294+ $ table = new cli \Table ();
295+ $ table ->setHeaders ( array ( 'Name ' , 'Age ' ) );
296+ $ table ->addRow ( array ( 'Alice ' , '30 ' ) );
297+ $ table ->addRow ( array ( 'Bob ' , '25 ' ) );
298+
299+ $ this ->assertEquals ( 2 , $ table ->countRows () );
300+
301+ $ table ->resetRows ();
302+
303+ $ this ->assertEquals ( 0 , $ table ->countRows () );
304+
305+ // Headers should still be intact
306+ $ out = $ table ->getDisplayLines ();
307+ $ this ->assertGreaterThan ( 0 , count ( $ out ) );
308+ }
309+
310+ public function test_displayRow_ascii () {
311+ $ mockFile = tempnam ( sys_get_temp_dir (), 'temp ' );
312+ $ resource = fopen ( $ mockFile , 'wb ' );
313+
314+ try {
315+ \cli \Streams::setStream ( 'out ' , $ resource );
316+
317+ $ table = new cli \Table ();
318+ $ renderer = new cli \Table \Ascii ();
319+ $ table ->setRenderer ( $ renderer );
320+ $ table ->setHeaders ( array ( 'Name ' , 'Age ' ) );
321+
322+ // Display a single row
323+ $ table ->displayRow ( array ( 'Alice ' , '30 ' ) );
324+
325+ $ output = file_get_contents ( $ mockFile );
326+
327+ // Should contain the row data
328+ $ this ->assertStringContainsString ( 'Alice ' , $ output );
329+ $ this ->assertStringContainsString ( '30 ' , $ output );
330+
331+ // Should contain borders
332+ $ this ->assertStringContainsString ( '| ' , $ output );
333+ $ this ->assertStringContainsString ( '+ ' , $ output );
334+ } finally {
335+ if ( $ mockFile && file_exists ( $ mockFile ) ) {
336+ unlink ( $ mockFile );
337+ }
338+ }
339+ }
340+
341+ public function test_displayRow_tabular () {
342+ $ mockFile = tempnam ( sys_get_temp_dir (), 'temp ' );
343+ $ resource = fopen ( $ mockFile , 'wb ' );
344+
345+ try {
346+ \cli \Streams::setStream ( 'out ' , $ resource );
347+
348+ $ table = new cli \Table ();
349+ $ renderer = new cli \Table \Tabular ();
350+ $ table ->setRenderer ( $ renderer );
351+ $ table ->setHeaders ( array ( 'Name ' , 'Age ' ) );
352+
353+ // Display a single row
354+ $ table ->displayRow ( array ( 'Alice ' , '30 ' ) );
355+
356+ $ output = file_get_contents ( $ mockFile );
357+
358+ // Should contain the row data with tabs
359+ $ this ->assertStringContainsString ( 'Alice ' , $ output );
360+ $ this ->assertStringContainsString ( '30 ' , $ output );
361+ } finally {
362+ if ( $ mockFile && file_exists ( $ mockFile ) ) {
363+ unlink ( $ mockFile );
364+ }
365+ }
366+ }
292367}
0 commit comments