Skip to content

Implemented unit test to track the visualisation bug in #127. #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/Output/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => "<bold>Robert Smith</end>", 'age' => '<yellow>30</end>'],
['name' => "<bold>Elizabeth Fraser</end>", 'age' => '<yellow>25</end>'],
];

$expectedOutput = implode(PHP_EOL, [
'+------------------+-----+',
'| Name | Age |',
'+------------------+-----+',
'| <bold>Robert Smith</end> | <yellow>30</end> |',
'| <bold>Elizabeth Fraser</end> | <yellow>25</end> |',
'+------------------+-----+'
]);

$result = $this->table->render($rows);

$this->assertSame($expectedOutput, trim($result));
}
}
Loading