From fa01ff72aa88d2149dead87af7a6581643400008 Mon Sep 17 00:00:00 2001 From: Adriano Cataluddi Date: Sun, 11 May 2025 11:17:46 +0200 Subject: [PATCH] Implemented unit test do track the visualisation bug in #127. --- tests/Output/TableTest.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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)); + } }