From 7214101725c6fb672dbc165f9e5f9c7947dfd9d0 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Sun, 2 Jul 2023 21:01:17 +0200 Subject: [PATCH] Add some simple tests for the parser --- tests/Helper/ParserTest.php | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 tests/Helper/ParserTest.php diff --git a/tests/Helper/ParserTest.php b/tests/Helper/ParserTest.php new file mode 100644 index 0000000..084d6d7 --- /dev/null +++ b/tests/Helper/ParserTest.php @@ -0,0 +1,70 @@ +Some test text

'; + + $this->assertEquals( + "\nSome test text\n\n", + Parser::parseHtml($text), + ); + } + + public function testSimpleNodeWithBold(): void + { + $text = '

Some test text

'; + + $this->assertEquals( + "\nSome \\textbf{test} text\n\n", + Parser::parseHtml($text), + ); + } + + public function testSimpleNodeWithItalic(): void + { + $text = '

Some test text

'; + + $this->assertEquals( + "\nSome \\textit{test} text\n\n", + Parser::parseHtml($text), + ); + } + + public function testDoubleNode(): void + { + $text = '

Some test text

'; + + $this->assertEquals( + "\n\\textbf{Some} \\textit{test} text\n\n", + Parser::parseHtml($text), + ); + } + + public function testDoubleOverlappingNode(): void + { + $text = '

Some test text

'; + + $this->assertEquals( + "\n\\textbf{Some \\textit{test}} text\n\n", + Parser::parseHtml($text), + ); + } + + public function testDoubleEqualNode(): void + { + $text = '

Some test text

'; + + $this->assertEquals( + "\nSome \\textbf{\\textit{test}} text\n\n", + Parser::parseHtml($text), + ); + } +}