diff --git a/tests/Output/TableTest.php b/tests/Output/TableTest.php index 682d872..d92ecd8 100644 --- a/tests/Output/TableTest.php +++ b/tests/Output/TableTest.php @@ -665,4 +665,33 @@ public function test_render_with_unicode_characters_in_cell_content(): void $this->assertSame($expectedOutput, trim($result)); } + + /** + * Tests the rendering of table data where cell content includes formatting tags. + * + * Validates that the table rendering properly handles formatting tags by not including their length in the final + * column width computation. + * + * @return void + */ + public function test_render_with_formatting_tags_in_cell_content(): void + { + $rows = [ + ['name' => "Robert Smith", 'age' => '30'], + ['name' => "Elizabeth Fraser", 'age' => '25'], + ]; + + $expectedOutput = implode(PHP_EOL, [ + '+------------------+-----+', + '| Name | Age |', + '+------------------+-----+', + '| Robert Smith | 30 |', + '| Elizabeth Fraser | 25 |', + '+------------------+-----+' + ]); + + $result = $this->table->render($rows); + + $this->assertSame($expectedOutput, trim($result)); + } }