]> git.mxchange.org Git - friendica.git/commitdiff
Add test for Text\Markdown::convert
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 10 Mar 2019 04:29:57 +0000 (23:29 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 10 Mar 2019 04:29:57 +0000 (23:29 -0500)
- Add folder for Markdown datasets

tests/datasets/content/text/markdown/bug-6633.html [new file with mode: 0644]
tests/datasets/content/text/markdown/bug-6633.md [new file with mode: 0644]
tests/src/Content/Text/MarkdownTest.php [new file with mode: 0644]

diff --git a/tests/datasets/content/text/markdown/bug-6633.html b/tests/datasets/content/text/markdown/bug-6633.html
new file mode 100644 (file)
index 0000000..313194e
--- /dev/null
@@ -0,0 +1,9 @@
+<h1>Produção de cebola em sistema orgânico com uso de homeopatia</h1>
+
+<p><img src="https://mapadaagroecologia.org/system/midias/imagems/000/000/097/original/Cebola_em_sistema_org%C3%A2nico.jpg?1549640469" alt="Bulbos de cebola em sistema orgânico na fase de colheita
+" title="Bulbos de cebola em sistema orgânico na fase de colheita
+" /></p>
+
+<h2><a href="https://mapadaagroecologia.org/locais/epagri-estacao-experimental-de-ituporanga-sc?locale=pt-BR">https://mapadaagroecologia.org/locais/epagri-estacao-experimental-de-ituporanga-sc?locale=pt-BR</a></h2>
+
+<p>#agroecologia #ecologia #orgânico #agroecology #brazil</p>
diff --git a/tests/datasets/content/text/markdown/bug-6633.md b/tests/datasets/content/text/markdown/bug-6633.md
new file mode 100644 (file)
index 0000000..330d491
--- /dev/null
@@ -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 (file)
index 0000000..e39b46b
--- /dev/null
@@ -0,0 +1,52 @@
+<?php\r
+\r
+namespace Friendica\Test\src\Content\Text;\r
+\r
+use Friendica\Content\Text\Markdown;\r
+use Friendica\Test\MockedTest;\r
+use Friendica\Test\Util\AppMockTrait;\r
+use Friendica\Test\Util\VFSTrait;\r
+\r
+class MarkdownTest extends MockedTest\r
+{\r
+       use VFSTrait;\r
+       use AppMockTrait;\r
+\r
+       protected function setUp()\r
+       {\r
+               parent::setUp();\r
+               $this->setUpVfsDir();\r
+               $this->mockApp($this->root);\r
+       }\r
+\r
+       public function dataMarkdown()\r
+       {\r
+               $inputFiles = glob(__DIR__ . '/../../../datasets/content/text/markdown/*.md');\r
+\r
+               $data = [];\r
+\r
+               foreach ($inputFiles as $file) {\r
+                       $data[str_replace('.md', '', $file)] = [\r
+                               'input'    => file_get_contents($file),\r
+                               'expected' => file_get_contents(str_replace('.md', '.html', $file))\r
+                       ];\r
+               }\r
+\r
+               return $data;\r
+       }\r
+\r
+       /**\r
+        * Test convert different input Markdown text into HTML\r
+        * @dataProvider dataMarkdown\r
+        *\r
+        * @param string $input    The Markdown text to test\r
+        * @param string $expected The expected HTML output\r
+        * @throws \Exception\r
+        */\r
+       public function testConvert($input, $expected)\r
+       {\r
+               $output = Markdown::convert($input);\r
+\r
+               $this->assertEquals($expected, $output);\r
+       }\r
+}
\ No newline at end of file