From 515935b241ee11afeea60de6a4954778ed41e6c3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 4 Aug 2019 10:24:25 -0400 Subject: [PATCH] Add test case for this bug - Fix whitespaces in MarkdownTest --- .../datasets/content/text/html/bug-7457.html | 1 + tests/datasets/content/text/html/bug-7457.txt | 5 + tests/src/Content/Text/HTMLTest.php | 53 +++++++++ tests/src/Content/Text/MarkdownTest.php | 104 +++++++++--------- 4 files changed, 111 insertions(+), 52 deletions(-) create mode 100644 tests/datasets/content/text/html/bug-7457.html create mode 100644 tests/datasets/content/text/html/bug-7457.txt create mode 100644 tests/src/Content/Text/HTMLTest.php diff --git a/tests/datasets/content/text/html/bug-7457.html b/tests/datasets/content/text/html/bug-7457.html new file mode 100644 index 000000000..4a2d4b33c --- /dev/null +++ b/tests/datasets/content/text/html/bug-7457.html @@ -0,0 +1 @@ +

[1.0.4] - 2019-08-01

Fixed

\ No newline at end of file diff --git a/tests/datasets/content/text/html/bug-7457.txt b/tests/datasets/content/text/html/bug-7457.txt new file mode 100644 index 000000000..051071d55 --- /dev/null +++ b/tests/datasets/content/text/html/bug-7457.txt @@ -0,0 +1,5 @@ +*[1.0.4] - 2019-08-01* + +*Fixed* + +* Invalid SemVer version generation, when the current branch does not have commits ahead of tag/checked out on a tag \ No newline at end of file diff --git a/tests/src/Content/Text/HTMLTest.php b/tests/src/Content/Text/HTMLTest.php new file mode 100644 index 000000000..65ae05249 --- /dev/null +++ b/tests/src/Content/Text/HTMLTest.php @@ -0,0 +1,53 @@ +setUpVfsDir(); + $this->mockApp($this->root); + } + + public function dataHTML() + { + $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/html/*.html'); + + $data = []; + + foreach ($inputFiles as $file) { + $data[str_replace('.html', '', $file)] = [ + 'input' => file_get_contents($file), + 'expected' => file_get_contents(str_replace('.html', '.txt', $file)) + ]; + } + + return $data; + } + + /** + * Test convert different input Markdown text into HTML + * + * @dataProvider dataHTML + * + * @param string $input The Markdown text to test + * @param string $expected The expected HTML output + * @throws \Exception + */ + public function testToPlaintext($input, $expected) + { + $output = HTML::toPlaintext($input, 0); + + $this->assertEquals($expected, $output); + } +} diff --git a/tests/src/Content/Text/MarkdownTest.php b/tests/src/Content/Text/MarkdownTest.php index e39b46b2c..80421b522 100644 --- a/tests/src/Content/Text/MarkdownTest.php +++ b/tests/src/Content/Text/MarkdownTest.php @@ -1,52 +1,52 @@ -setUpVfsDir(); - $this->mockApp($this->root); - } - - public function dataMarkdown() - { - $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md'); - - $data = []; - - foreach ($inputFiles as $file) { - $data[str_replace('.md', '', $file)] = [ - 'input' => file_get_contents($file), - 'expected' => file_get_contents(str_replace('.md', '.html', $file)) - ]; - } - - return $data; - } - - /** - * Test convert different input Markdown text into HTML - * @dataProvider dataMarkdown - * - * @param string $input The Markdown text to test - * @param string $expected The expected HTML output - * @throws \Exception - */ - public function testConvert($input, $expected) - { - $output = Markdown::convert($input); - - $this->assertEquals($expected, $output); - } -} \ No newline at end of file +setUpVfsDir(); + $this->mockApp($this->root); + } + + public function dataMarkdown() + { + $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md'); + + $data = []; + + foreach ($inputFiles as $file) { + $data[str_replace('.md', '', $file)] = [ + 'input' => file_get_contents($file), + 'expected' => file_get_contents(str_replace('.md', '.html', $file)) + ]; + } + + return $data; + } + + /** + * Test convert different input Markdown text into HTML + * @dataProvider dataMarkdown + * + * @param string $input The Markdown text to test + * @param string $expected The expected HTML output + * @throws \Exception + */ + public function testConvert($input, $expected) + { + $output = Markdown::convert($input); + + $this->assertEquals($expected, $output); + } +}