From 80ee411f4576163ffc084d27bb842d5b8e2d7119 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 9 Mar 2019 23:29:57 -0500 Subject: [PATCH] Add test for Text\Markdown::convert - Add folder for Markdown datasets --- .../content/text/markdown/bug-6633.html | 9 ++++ .../content/text/markdown/bug-6633.md | 9 ++++ tests/src/Content/Text/MarkdownTest.php | 52 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/datasets/content/text/markdown/bug-6633.html create mode 100644 tests/datasets/content/text/markdown/bug-6633.md create mode 100644 tests/src/Content/Text/MarkdownTest.php diff --git a/tests/datasets/content/text/markdown/bug-6633.html b/tests/datasets/content/text/markdown/bug-6633.html new file mode 100644 index 0000000000..313194e023 --- /dev/null +++ b/tests/datasets/content/text/markdown/bug-6633.html @@ -0,0 +1,9 @@ +

Produção de cebola em sistema orgânico com uso de homeopatia

+ +

Bulbos de cebola em sistema orgânico na fase de colheita
+

+ +

https://mapadaagroecologia.org/locais/epagri-estacao-experimental-de-ituporanga-sc?locale=pt-BR

+ +

#agroecologia #ecologia #orgânico #agroecology #brazil

diff --git a/tests/datasets/content/text/markdown/bug-6633.md b/tests/datasets/content/text/markdown/bug-6633.md new file mode 100644 index 0000000000..330d491679 --- /dev/null +++ b/tests/datasets/content/text/markdown/bug-6633.md @@ -0,0 +1,9 @@ +# Produção de cebola em sistema orgânico com uso de homeopatia + +![Bulbos de cebola em sistema orgânico na fase de colheita +](https://mapadaagroecologia.org/system/midias/imagems/000/000/097/original/Cebola_em_sistema_org%C3%A2nico.jpg?1549640469 "Bulbos de cebola em sistema orgânico na fase de colheita +") + +## https://mapadaagroecologia.org/locais/epagri-estacao-experimental-de-ituporanga-sc?locale=pt-BR + +#agroecologia #ecologia #orgânico #agroecology #brazil \ No newline at end of file diff --git a/tests/src/Content/Text/MarkdownTest.php b/tests/src/Content/Text/MarkdownTest.php new file mode 100644 index 0000000000..e39b46b2c5 --- /dev/null +++ b/tests/src/Content/Text/MarkdownTest.php @@ -0,0 +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