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); + } +}