From 6f1fac982335c6c7571f009b10a78ee8f2bad9c5 Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Fri, 5 Sep 2014 23:12:33 +0300 Subject: [PATCH 1/2] Add Standard Markdown testsuite. You could run the Parsedown testsuite only with: phpunit --testsuite ParsedownTests And you could run the Standard Markdown one with: phpunit --testsuite StandardMarkdown See more at http://standardmarkdown.com/ --- .travis.yml | 3 +- phpunit.xml.dist | 9 ++- test/standard-markdown/.gitignore | 1 + .../StandardMarkdownTest.php | 60 +++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 test/standard-markdown/.gitignore create mode 100644 test/standard-markdown/StandardMarkdownTest.php diff --git a/.travis.yml b/.travis.yml index dade257..cf9fc06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,5 @@ php: - 5.3 - 5.2 - hhvm - \ No newline at end of file + +before_script: curl -sS https://raw.githubusercontent.com/jgm/stmd/master/spec.txt>test/standard-markdown/spec.txt diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 875167a..80a08b6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,11 @@ - - test/Test.php + + test/Test.php + + + test/standard-markdown/StandardMarkdownTest.php - \ No newline at end of file + diff --git a/test/standard-markdown/.gitignore b/test/standard-markdown/.gitignore new file mode 100644 index 0000000..99ba414 --- /dev/null +++ b/test/standard-markdown/.gitignore @@ -0,0 +1 @@ +spec.txt diff --git a/test/standard-markdown/StandardMarkdownTest.php b/test/standard-markdown/StandardMarkdownTest.php new file mode 100644 index 0000000..c66b3c4 --- /dev/null +++ b/test/standard-markdown/StandardMarkdownTest.php @@ -0,0 +1,60 @@ +(.|[\n])*/m', '', $spec); + + preg_replace_callback( + '/^\.\n([\s\S]*?)^\.\n([\s\S]*?)^\.$|^#{1,6} *(.*)$/m', + function($matches) use (&$tests, &$currentSection, &$testsCount) { + if (isset($matches[3]) and $matches[3]) { + $currentSection = $matches[3]; + } else { + $testsCount++; + $markdown = preg_replace('/→/', "\t", $matches[1]); + $tests []= array( + $markdown, // markdown + $matches[2], // html + $currentSection, // section + $testsCount, // number + ); + } + }, + $spec + ); + + return $tests; + } + + /** + * @dataProvider getStandardMarkdownRules + */ + public function testAgainstStandardMarkdown($markdown, $expectedHtml, $section, $number) + { + $parsedown = new Parsedown(); + + $actualHtml = $parsedown->text($markdown); + + // Trim for better compatibility of the HTML output + $actualHtml = trim($actualHtml); + $expectedHtml = trim($expectedHtml); + + $this->assertEquals($expectedHtml, $actualHtml); + } +} From c18ff7f370901fd7bd803d3bc0a71fe321e9090d Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Fri, 5 Sep 2014 23:28:07 +0300 Subject: [PATCH 2/2] Add Docblock and attribution to JS test runner --- test/standard-markdown/StandardMarkdownTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/standard-markdown/StandardMarkdownTest.php b/test/standard-markdown/StandardMarkdownTest.php index c66b3c4..c01f331 100644 --- a/test/standard-markdown/StandardMarkdownTest.php +++ b/test/standard-markdown/StandardMarkdownTest.php @@ -1,5 +1,13 @@