diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2024-02-06 16:19:30 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2024-02-06 16:19:30 +0100 |
commit | eb6a143fffba5a796945a425b289e95f7bd28d00 (patch) | |
tree | 14a42ec53ad6917275fb689c6ecd4d744dbf6abd | |
parent | 1881029040245bb5b097ccdc3da64ef7581e9169 (diff) | |
download | volse-hubzilla-eb6a143fffba5a796945a425b289e95f7bd28d00.tar.gz volse-hubzilla-eb6a143fffba5a796945a425b289e95f7bd28d00.tar.bz2 volse-hubzilla-eb6a143fffba5a796945a425b289e95f7bd28d00.zip |
Add some tests for markdown to bbcode conversion.
-rw-r--r-- | tests/unit/includes/MarkdownTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/includes/MarkdownTest.php b/tests/unit/includes/MarkdownTest.php index 25c947824..71f13cdb0 100644 --- a/tests/unit/includes/MarkdownTest.php +++ b/tests/unit/includes/MarkdownTest.php @@ -31,6 +31,43 @@ require_once 'include/markdown.php'; * @brief Unit Test case for markdown functions. */ class MarkdownTest extends UnitTestCase { + + /** + * @dataProvider markdown_to_bbcode_provider + */ + public function test_markdown_to_bbcode(string $expected, string $src): void { + $this->assertEquals($expected, markdown_to_bb($src)); + } + + private function markdown_to_bbcode_provider(): array { + return [ + 'empty text' => [ + '', + '' + ], + 'plain text' => [ + 'This is a test', + 'This is a test' + ], + 'bold and italic' => [ + 'This is a test of [b]bold text[/b], [i]italic text[/i] and [b][i]bold and italic text[/i][/b]', + 'This is a test of **bold text**, *italic text* and ***bold and italic text***' + ], + 'multiline text' => [ + 'This text is text wrapped over multiple lines.', + "This text is\ntext wrapped\nover multiple\nlines." + ], + 'paragraphs' => [ + "Paragraph one\n\nParagraph two", + "Paragraph one\n\nParagraph two", + ], + 'inline image' => [ + '[img=https://example.com/image.jpg]https://example.com/image.jpg[/img]', + '![](https://example.com/image.jpg)' + ], + ]; + } + /** * @covers ::html2markdown * @dataProvider html2markdownProvider |