Skip to content

Commit

Permalink
Add some simple tests for the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver committed Jul 2, 2023
1 parent 176c076 commit 7214101
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/Helper/ParserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Helper;

use Bobv\LatexBundle\Helper\Parser;
use PHPUnit\Framework\TestCase;

class ParserTest extends TestCase
{

public function testSimpleNode(): void
{
$text = '<p>Some test text</p>';

$this->assertEquals(
"\nSome test text\n\n",
Parser::parseHtml($text),
);
}

public function testSimpleNodeWithBold(): void
{
$text = '<p>Some <b>test</b> text</p>';

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

public function testSimpleNodeWithItalic(): void
{
$text = '<p>Some <em>test</em> text</p>';

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

public function testDoubleNode(): void
{
$text = '<p><b>Some</b> <em>test</em> text</p>';

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

public function testDoubleOverlappingNode(): void
{
$text = '<p><b>Some <em>test</em></b> text</p>';

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

public function testDoubleEqualNode(): void
{
$text = '<p>Some <b><em>test</em></b> text</p>';

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

0 comments on commit 7214101

Please sign in to comment.