Skip to content

Commit fa01ff7

Browse files
committed
Implemented unit test do track the visualisation bug in #127.
1 parent e380f7c commit fa01ff7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Output/TableTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,33 @@ public function test_render_with_unicode_characters_in_cell_content(): void
665665

666666
$this->assertSame($expectedOutput, trim($result));
667667
}
668+
669+
/**
670+
* Tests the rendering of table data where cell content includes formatting tags.
671+
*
672+
* Validates that the table rendering properly handles formatting tags by not including their length in the final
673+
* column width computation.
674+
*
675+
* @return void
676+
*/
677+
public function test_render_with_formatting_tags_in_cell_content(): void
678+
{
679+
$rows = [
680+
['name' => "<bold>Robert Smith</end>", 'age' => '<yellow>30</end>'],
681+
['name' => "<bold>Elizabeth Fraser</end>", 'age' => '<yellow>25</end>'],
682+
];
683+
684+
$expectedOutput = implode(PHP_EOL, [
685+
'+------------------+-----+',
686+
'| Name | Age |',
687+
'+------------------+-----+',
688+
'| <bold>Robert Smith</end> | <yellow>30</end> |',
689+
'| <bold>Elizabeth Fraser</end> | <yellow>25</end> |',
690+
'+------------------+-----+'
691+
]);
692+
693+
$result = $this->table->render($rows);
694+
695+
$this->assertSame($expectedOutput, trim($result));
696+
}
668697
}

0 commit comments

Comments
 (0)